Skip to content

fix: replace 500 error with bad request due to bitbucket returning 429#6872

Open
mathnogueira wants to merge 7 commits into
mainfrom
fix/intercept-429-bitbucket
Open

fix: replace 500 error with bad request due to bitbucket returning 429#6872
mathnogueira wants to merge 7 commits into
mainfrom
fix/intercept-429-bitbucket

Conversation

@mathnogueira

@mathnogueira mathnogueira commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Context

We had a customer complaining about bitbucket failing with 500 error. However, after investigation, it was failing because BitBucket was returning 429 errors.

We, unfortunately, cannot give more details because BitBucket doesn't return more information: for example, how long to wait. Bitbucket rate limit windows are 1h long.

Screenshots

Steps to verify the change

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Updated docs (if needed)
  • Updated CLAUDE.md files (if needed)
  • Read the contributing guide

@infisical-review-police

Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-infisical-6872-fix-replace-500-error-with-bad-request-due-to-bitbucket

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a misleading 500 error that appeared when Bitbucket returned a 429 Too Many Requests response. A new ensureBitbucketRateLimitNotExceeded helper is introduced and called in the catch block of every listing function to convert 429 AxiosErrors into user-friendly BadRequestErrors before they propagate.

  • All four listing functions (listBitbucketWorkspaces, paginateBitbucketRequest, listBitbucketRepositories, listBitbucketEnvironments) are wrapped in try/catch; the helper always throws (returns never), so error-path control flow is preserved correctly.
  • Non-429 errors are re-thrown unchanged by the helper, maintaining existing error propagation behavior.

Confidence Score: 5/5

The change is narrowly scoped and safe to merge.

The change wraps existing pagination loops in try/catch blocks and translates 429 errors into user-facing BadRequestErrors. The helper always throws (never-returning), so no silent swallowing of errors occurs. All four affected functions were updated consistently and the fix matches the described root cause.

No files require special attention.

Important Files Changed

Filename Overview
backend/src/services/app-connection/bitbucket/bitbucket-connection-fns.ts Adds ensureBitbucketRateLimitNotExceeded helper and wraps all four Bitbucket listing functions in try/catch to convert 429 AxiosErrors into user-friendly BadRequestErrors; logic is correct and consistently applied.

Reviews (2): Last reviewed commit: "fix lint issues" | Re-trigger Greptile

Comment thread backend/src/services/app-connection/bitbucket/bitbucket-connection-fns.ts Outdated
@mathnogueira

Copy link
Copy Markdown
Contributor Author

@greptile review this again

@mathnogueira mathnogueira requested review from varonix0 and removed request for varonix0 June 15, 2026 23:09
}

return environments;
return paginateBitbucketRequest<TBitbucketEnvironment>(

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.

environments don't support searching by a term, so it's the only endpoint we still need to run this logic.

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.

1 participant