Skip to content

fix(appset): clean error message for missing BitBucket branch hash - #30981

Open
AP24110011695 wants to merge 1 commit into
argoproj:masterfrom
AP24110011695:fix/bitbucket-sha-error-message
Open

AP24110011695 wants to merge 1 commit into
argoproj:masterfrom
AP24110011695:fix/bitbucket-sha-error-message

Conversation

@AP24110011695

@AP24110011695 AP24110011695 commented Nov 12, 2026 •

Copy link
Copy Markdown

Fixes #30980

What

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.

Signed-off-by: Ayush Kumar Saha 225407166+AP24110011695@users.noreply.github.com

Summary by CodeRabbit

  • Bug Fixes
    • 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.

Signed-off-by: Ayush Kumar Saha <225407166+AP24110011695@users.noreply.github.com>
@AP24110011695
AP24110011695 requested a review from a team as a code owner November 12, 2026 22:06
@bunnyshell

bunnyshell Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

❗ Preview Environment deployment failed on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🚀 /bns:deploy to redeploy the environment
  • ❌ /bns:delete to remove the environment

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: mmorel-35, ppapapetrou76

Merge Risk: Minimal · up to 3e5cc

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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 Passed 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(&lt;nil&gt;) 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c542d58-37fa-4ee1-9db5-6003709d7e05
Commits

Reviewing files that changed from the base of the PR and between 45b9dcf and 3e5cc86.

Files selected for processing: 2

  • applicationset/services/scm_provider/bitbucket_cloud.go
  • applicationset/services/scm_provider/bitbucket_cloud_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 182 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
argo-cd-ui-array-push 12.22MB 182 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: argo-cd-ui-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
main.*.js 182 bytes 222.02kB 0.08%

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ 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.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #30981      +/-   ##
==========================================
+ Coverage   73.32%   73.33%   +0.01%     
==========================================
  Files         442      442              
  Lines       57775    57775              
==========================================
+ Hits        42366    42372       +6     
+ Misses      15409    15403       -6     
Flag Coverage Δ
e2e 30.66% <0.00%> (-0.03%) ⬇️
unit-tests 69.12% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

No deployments
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.

ApplicationSet: BitBucket Cloud SCM provider returns corrupted error (%!w(<nil>)) when a branch has no commit hash

1 participant