You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the BitBucket Cloud SCM provider lists branches whose target.hash is missing or not a string, GetBranches failed with a corrupted message ending in %!w(<nil>):
error getting SHA for branch for test-owner/testmike/main: %!w(<nil>)
Root cause
err is checked non-nil and returned at the top of GetBranches (the listBranches call), so past that point it is guaranteed nil — but the !ok branch in the hash extraction still formatted the message with %w, err. Same defect class as #30855 (fixed in the list generator).
Fix
The message no longer uses %w (there is no underlying error) — it names the branch and the actual condition:
error getting SHA for branch "main" of test-owner/testmike: the commit hash is missing or not a string
Tests
TestBitbucketGetBranchesMissingHash — a stub BitBucket API returning a branch with an empty target; asserts the clean message and that %!w never appears. Fails on master with the corrupted output (verified by probe on 45b9dcf before this change).
go test ./applicationset/services/scm_provider/ -count=1 passes fully; go vet clean; gofumpt clean.
AI disclosure
This contribution was prepared with AI assistance (Claude); the analysis, fix, and tests were reviewed and verified by me before submission.
Improved error reporting when a Bitbucket branch response is missing a valid commit hash. The error now identifies the affected branch and repository and describes the invalid hash, instead of showing a misleading branch-listing error.
No actionable comments were generated in the recent review.
Walkthrough
GetBranches now returns an error that identifies the branch and repository when a branch has no string commit hash. A test checks the error message and confirms it does not contain a malformed %!w artifact.
Changes: Bitbucket Cloud branch hash error
Layer / File(s)
Summary
Missing-hash error and test applicationset/services/scm_provider/bitbucket_cloud.go, applicationset/services/scm_provider/bitbucket_cloud_test.go
GetBranches now reports the branch, repository, and missing or non-string hash condition. The new test checks the error content and absence of a malformed %!w artifact.
This change makes the error for a Bitbucket branch with a missing commit hash clearer, and it adds a test. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: the BitBucket Cloud branch-hash error message is cleaned up in the appset SCM provider. It matches the raw summary and the PR objectives, and it is specific enough for…
Description check
The description follows the template's main purpose. It links issue #30980 with "Fixes", explains the what and root cause, describes the fix, and lists the tests and verification steps. It includes an…
Linked Issues check
Issue #30980 requires a clean GetBranches error when a BitBucket Cloud branch has a missing or non-string target.hash. The error must name the branch and state the condition. The diff in bitbucket_clo…
Out of Scope Changes check
The whole-PR diff against merge base 45b9dcf changes two files. bitbucket_cloud.go changes only the one error line in the hash-extraction branch of GetBranches. bitbucket_cloud_test.go adds one test…
Full details: Title check
Explanation
The title names the main change: the BitBucket Cloud branch-hash error message is cleaned up in the appset SCM provider. It matches the raw summary and the PR objectives, and it is specific enough for a teammate scanning history. The 66-character length is within a normal range.
Full details: Description check
Explanation
The description follows the template's main purpose. It links issue #30980 with "Fixes", explains the what and root cause, describes the fix, and lists the tests and verification steps. It includes an AI disclosure and a Signed-off-by line. Several template checklist items are not addressed in the body, such as documentation updates, the release-note choice, the CLI/UI note, and the USERS.md and cherry-pick options. These are non-critical, so the description is mostly complete.
Full details: Linked Issues check
Explanation
Issue #30980 requires a clean GetBranches error when a BitBucket Cloud branch has a missing or non-string target.hash. The error must name the branch and state the condition. The diff in bitbucket_cloud.go replaces the %w format verb with a message that names the branch, the owner/repository, and the condition: error getting SHA for branch %q of %s/%s: the commit hash is missing or not a string. The err argument is removed, so no %!w(<nil>) output remains. The added test TestBitbucketGetBranchesMissingHash uses a stub API that returns a branch with an empty target. It asserts the expected message and that %!w is absent. The test covers the reported behavior. No unmet coding requirement was found.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against merge base 45b9dcf changes two files. bitbucket_cloud.go changes only the one error line in the hash-extraction branch of GetBranches. bitbucket_cloud_test.go adds one test function that exercises that same error path. No unrelated changes were found.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.33%. Comparing base (e263590) to head (3e5cc86). ⚠️ Report is 3 commits behind head on master.
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
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.
Fixes #30980
What
When the BitBucket Cloud SCM provider lists branches whose
target.hashis missing or not a string,GetBranchesfailed with a corrupted message ending in%!w(<nil>):Root cause
erris checked non-nil and returned at the top ofGetBranches(the listBranches call), so past that point it is guaranteed nil — but the!okbranch in the hash extraction still formatted the message with%w, err. Same defect class as #30855 (fixed in the list generator).Fix
The message no longer uses
%w(there is no underlying error) — it names the branch and the actual condition:Tests
TestBitbucketGetBranchesMissingHash— a stub BitBucket API returning a branch with an empty target; asserts the clean message and that%!wnever appears. Fails on master with the corrupted output (verified by probe on 45b9dcf before this change).go test ./applicationset/services/scm_provider/ -count=1passes fully;go vetclean; gofumpt clean.AI disclosure
This contribution was prepared with AI assistance (Claude); the analysis, fix, and tests were reviewed and verified by me before submission.
Signed-off-by: Ayush Kumar Saha 225407166+AP24110011695@users.noreply.github.com
Summary by CodeRabbit