Skip to content

[OJ-54730] Catch HTTPError when fetching BB Cloud PR merge commit#454

Merged
lheureuxe13 merged 3 commits into
masterfrom
OJ-54730-bb-cloud-catch
May 18, 2026
Merged

[OJ-54730] Catch HTTPError when fetching BB Cloud PR merge commit#454
lheureuxe13 merged 3 commits into
masterfrom
OJ-54730-bb-cloud-catch

Conversation

@lheureuxe13
Copy link
Copy Markdown
Contributor

@lheureuxe13 lheureuxe13 commented May 18, 2026

Summary

  • Wraps the client.get_commit(...) call for a PR's merge_commit in jf_agent/git/bitbucket_cloud_adapter.py with a try/except requests.exceptions.HTTPError, so a garbage-collected merge commit no longer raises and causes the entire PR to be dropped with [3011] Error normalizing PR ....
  • Mirrors the existing pattern in monorepo: on HTTPError, log the hash + status code and leave merge_commit=None. The PR is still ingested with all other fields intact.

Mirrors the existing pattern in jf_github/adapters/bitbucket_cloud.py so a
garbage-collected merge commit returns merge_commit=None instead of
skipping the entire PR.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Bitbucket Cloud PR normalization so missing or inaccessible merge commit objects do not cause the entire PR ingestion to fail.

Changes:

  • Wraps merge commit retrieval in try/except requests.exceptions.HTTPError.
  • Logs the merge commit hash and HTTP status when retrieval fails, leaving merge_commit=None.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +528 to +529
logger.info(
f'For merge commit {merge_commit_hash} received a {e.response.status_code} while retrieving PR commits'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a regression test in commit 08c794a: test_get_prs_merge_commit_404_does_not_skip_pr stubs client.get_commit to raise HTTPError(404) and asserts the PR is still returned with merge_commit=None.

Verifies that when client.get_commit raises HTTPError(404), the PR is
still returned with merge_commit=None instead of being skipped.
- Add return type hint to test method.
- Replace hex-like merge hash literal with a non-hex placeholder so the
  detect-secrets pragma comment is no longer needed.
@sonarqubecloud
Copy link
Copy Markdown

@lheureuxe13 lheureuxe13 merged commit 7505261 into master May 18, 2026
7 checks passed
@lheureuxe13 lheureuxe13 deleted the OJ-54730-bb-cloud-catch branch May 18, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants