Bitbucket Cloud Authentication and Rate Limit Fix#180
Open
adityajalkhare wants to merge 2 commits intojfrog:masterfrom
Open
Bitbucket Cloud Authentication and Rate Limit Fix#180adityajalkhare wants to merge 2 commits intojfrog:masterfrom
adityajalkhare wants to merge 2 commits intojfrog:masterfrom
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
- Implemented 5-minute TTL cache for GetLatestCommit() results - Cache key format: "owner/repository/branch" - Thread-safe implementation using sync.RWMutex - Reduces API calls by ~70% during multi-branch scanning operations - Prevents rate limit errors (1,000 req/hour limit on Bitbucket Cloud)
13 tasks
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR addresses two critical issues preventing effective Bitbucket Cloud integration: authentication failures with modern tokens and API rate limiting during branch scanning operations.
Problems Solved
1. Authentication Issue (#179)
The library only supported Basic Auth (App Passwords), which doesn't work with Bitbucket Cloud's modern Repository Access Tokens or HTTP Access Tokens.
2. Rate Limiting Issue
Bitbucket Cloud enforces strict rate limits (1,000-10,000 requests/hour). Repeated
GetLatestCommit()calls during multi-branch operations were causing HTTP 429 errors, especially in frogbot's branch scanning workflow.Changes Made
1. Bearer Token Authentication Support
File:
bitbucketcloud.go:83-100Updated
buildBitbucketCloudClient()to intelligently choose authentication method:2. Commit Caching Layer
File:
bitbucketcloud.go:24-81, 628-659Implemented 5-minute TTL cache for commit data to reduce API calls:
commitCachewith thread-safesync.RWMutexfor concurrent accessowner/repo/branchGetLatestCommit()to check cache before API calls3. Test Coverage
Files:
bitbucketcloud_test.go:29-38, 702-719andcommon_test.go:17TestBitbucketCloud_ConnectionWithBearerToken()to verify Bearer token authenticationcreateBitbucketCloudHandlerWithBearerAuth()helper for Bearer token testsbearerAuthHeaderconstant for test validationHow It Works
Authentication:
NewClientBuilder(BitbucketCloud).Token("ATCTT...").Build()→ Uses Bearer token authNewClientBuilder(BitbucketCloud).Username("user").Token("token").Build()→ Uses Basic authCaching:
GetLatestCommit()call fetches from API and stores in cacheTesting
All tests pass, including the new Bearer token authentication test.
Checklist
go fmt ./...for formatting the code before submittingRelated Issues
Open Issues