Repository navigation
fix(bitbucket): propagate repo context fetch errors - #2791
IsmaelMartinez merged 3 commits into
Conversation
PR Summary by QodoPropagate Bitbucket repo-context fetch errors (keep empty-string for direct calls)
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks for the second Bitbucket fix today. The verdict is yes, and the case is stronger than the description makes it: measured on main, a 500 puts the error page into <instruction_files> as project guidance and caches it for the 15-minute TTL, so it outlives the outage that caused it.
| # or from the repository default branch when from_default_branch is requested. | ||
| branch = self.get_repo_default_branch() if from_default_branch else self.pr.destination_branch | ||
| return self.get_pr_file_content(file_path, branch) | ||
| return self.get_pr_file_content(file_path, branch, propagate_errors=True) |
There was a problem hiding this comment.
This matches GitHub and Gitea, which already return "" only on 404 and let the rest propagate, for the reason spelled out in the comment above each. GitLab, Azure DevOps and Bitbucket Server still return "" when the fetch itself fails rather than only when the file is missing, so they cache an empty context instead. Worth a follow-up issue rather than widening this PR.
There was a problem hiding this comment.
Agreed. I kept the GitLab, Azure DevOps, and Bitbucket Server behavior out of this PR and prepared a separate follow-up issue covering their non-404 fetch failures being converted to empty repo context. The scope stays limited to those three providers, while GitHub and Gitea already propagate unexpected fetch errors.
| return self._get_repo().pullrequests.get(self.pr_num) | ||
|
|
||
| def get_pr_file_content(self, file_path: str, branch: str) -> str: | ||
| def get_pr_file_content(self, file_path: str, branch: str, propagate_errors: bool = False) -> str: |
There was a problem hiding this comment.
Does the flag need to exist? /update_changelog is the only other caller and it already wraps this in try/except, falling back to an empty changelog. As it stands it still takes a 500 error page as the existing CHANGELOG.md, which is the same defect one call away.
Defaulting propagate_errors to True closes that as well, and the suite stays green.
There was a problem hiding this comment.
Thanks, agreed. In follow-up commit b906b60d, I changed propagate_errors to default to True, so direct CHANGELOG.md reads no longer treat a non-404 error page as file content. /update_changelog already catches the propagated exception and falls back to an empty changelog.
I also added a regression test for the direct get_pr_file_content() path, while preserving the 404-as-missing behavior. The scoped provider/changelog/repo-context tests pass (92 tests), and the full unit suite passes (2035 passed). I kept the GitLab, Azure DevOps, and Bitbucket Server behavior out of this PR and prepared a separate follow-up issue.
|
Code review by qodo was updated up to the latest commit b906b60 |
|
Code review by qodo was updated up to the latest commit b4f0bb6 |
Fixes #2790.
Summary
get_pr_file_contentcallers, whose higher-level callers handle the exception; andTests
PYTHONPATH=. /tmp/pr-agent-full-venv/bin/pytest tests/unittest/test_bitbucket_provider.py tests/unittest/test_repo_context.py -q— 76 passedPYTHONPATH=. /tmp/pr-agent-full-venv/bin/pytest tests/unittest/test_bitbucket_provider.py tests/unittest/test_pr_update_changelog.py tests/unittest/test_repo_context.py -q— 92 passedPYTHONPATH=. /tmp/pr-agent-full-venv/bin/pytest tests/unittest -q— 2035 passed, 1 skipped, 1 xfailed, 90 warningsgit diff --check