Repository navigation
Update event handling for pull request updates - #2637
IsmaelMartinez merged 8 commits into
Conversation
Use correct bitbucket eventKey "pr:from_ref_updated"
PR Summary by QodoFix Bitbucket PR update webhook eventKey handling
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Dropped refs_changed support
|
Code Review by Qodo
1. Single-quoted command key
|
|
Code review by qodo was updated up to the latest commit e0324f8 |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Verified: merges clean, full suite passes at 2031. The change is right, and the old code proves it - the else branch comment already said "Has to be: pr:from_ref_updated", but the condition above it only ever matched pr:opened or repo:refs_changed, so for that event the branch was unreachable.
Could you add a test? tests/unittest/ has webhook tests to copy from, and this is the kind of event-routing fix that quietly regresses.
…hook-event-key Add unit test
|
Code review by qodo was updated up to the latest commit 80ce524 |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for adding the test.
Your pr:from_ref_updated case is doing its job: it goes red against main's source and green against yours, so the change itself is right.
The rewritten import block is the problem, and build-and-test is now failing on it. Suggestion inline.
| import copy | ||
| import importlib | ||
| from types import SimpleNamespace | ||
| import json | ||
|
|
||
| import pytest | ||
| from starlette.testclient import TestClient | ||
| from starlette.background import BackgroundTasks | ||
| from starlette_context import request_cycle_context | ||
|
|
||
| import pr_agent.servers.bitbucket_server_webhook as bitbucket_server_webhook | ||
| from pr_agent.config_loader import get_settings | ||
| from pr_agent.identity_providers.identity_provider import Eligibility | ||
| from pr_agent.servers import bitbucket_server_webhook, github_app | ||
|
|
||
|
|
There was a problem hiding this comment.
This drops SimpleNamespace, TestClient, Eligibility and github_app, which are still used from line 251 to 408, so 15 existing tests in this file fail. Restoring them, plus the blank line the rewrite removed, gives 34 of 34 here and keeps ruff clean.
| import copy | |
| import importlib | |
| from types import SimpleNamespace | |
| import json | |
| import pytest | |
| from starlette.testclient import TestClient | |
| from starlette.background import BackgroundTasks | |
| from starlette_context import request_cycle_context | |
| import pr_agent.servers.bitbucket_server_webhook as bitbucket_server_webhook | |
| from pr_agent.config_loader import get_settings | |
| from pr_agent.identity_providers.identity_provider import Eligibility | |
| from pr_agent.servers import bitbucket_server_webhook, github_app | |
| import copy | |
| import importlib | |
| import json | |
| from types import SimpleNamespace | |
| import pytest | |
| from starlette.background import BackgroundTasks | |
| from starlette.testclient import TestClient | |
| from starlette_context import request_cycle_context | |
| from pr_agent.config_loader import get_settings | |
| from pr_agent.identity_providers.identity_provider import Eligibility | |
| from pr_agent.servers import bitbucket_server_webhook, github_app | |
| # push event; -1 for push unassigned to a PR: Check auto commands for creation/updating | ||
| if (data["eventKey"] == "pr:opened" | ||
| or (data["eventKey"] == "repo:refs_changed" and data.get("pullRequest", {}).get("id", -1) != -1)): # push event; -1 for push unassigned to a PR: #Check auto commands for creation/updating | ||
| or (data["eventKey"] in ["pr:from_ref_updated", "repo:refs_changed"] |
There was a problem hiding this comment.
Trailing whitespace here; the repo has an active trailing-whitespace pre-commit hook.
| or (data["eventKey"] in ["pr:from_ref_updated", "repo:refs_changed"] | |
| or (data["eventKey"] in ["pr:from_ref_updated", "repo:refs_changed"] |
The import block rewrite removed SimpleNamespace, TestClient, Eligibility and github_app, which the GitHub and GitLab draft-setting tests still use, so 15 tests in the file failed. Also drops the trailing whitespace on the new eventKey line. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Code review by qodo was updated up to the latest commit f7a5bc5 |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
I pushed the import restore rather than leave you another round, plus the trailing whitespace on the new eventKey line. That file is back to 34 of 34 and build-and-test is green.
Thanks for adding the test, that is the part that made this easy to confirm.
The CI image installs from pyproject.toml and then deletes it, so asyncio_mode = "auto" is not in effect there and an unmarked async test is skipped as unsupported. Every other async test in this file carries the marker for the same reason. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Code review by qodo was updated up to the latest commit 5317000 |
Use correct bitbucket eventKey "pr:from_ref_updated" so pr review triggers on updates being pushed to the pr.