fix(cloud-agent-next): preserve bitbucket capability origin in worker sanitize - #4876
Merged
Merged
Conversation
… sanitize The worker-side sanitizeBitbucketCodeReviewRemote unconditionally stripped the bitbucket origin credential for any code-review session. Mirror the wrapper: skip the strip when the session is credential-contained, so a kbb1. capability origin stays authenticated for a blobless clone's lazy fetches instead of being wiped. Adds cold- and warm-path tests (per #4872 review) asserting a contained bitbucket review does not strip the origin and does not run the warm-resume token refresh. Removing the guard makes both tests fail, confirming they cover the regression.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryReviewed the bitbucket capability-preservation fix and its two new cold/warm-path regression tests; the change is small, correctly gated by Files Reviewed (2 files)
Reviewed by claude-sonnet-5 · Input: 34 · Output: 10.2K · Cached: 1.1M Review guidance: REVIEW.md from base branch |
RSO
approved these changes
Jul 30, 2026
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.
Summary
The worker-side
sanitizeBitbucketCodeReviewRemoteinsession-service.tsunconditionally stripped the credential from a Bitbucket code-review origin. For
a credential-contained session, that origin holds a
kbb1.outbound capabilitythat must stay in place so a blobless clone's lazy blob fetches can authenticate
through the outbound interceptor. This adds a guard that skips the strip when the
session is contained, mirroring the wrapper's
sanitizeBitbucketCodeReviewRemote.Follows up on a review comment on #4872.
Changes
session-service.ts: insanitizeBitbucketCodeReviewRemote, return early andleave the origin untouched when
getEffectiveCredentialContainment(metadata).bitbucketis true. A non-contained (raw-token) session is still stripped as before.
session-service.test.ts: added cold and warmprepareWorkspacetests for acontained Bitbucket review, asserting the origin is not stripped
(
updateGitRemoteUrlnot called) and, on warm resume, the token refresh isskipped (
updateGitRemoteTokennot called). Added anissueCloudAgentBitbucketSessionCapabilitymock and a containment override tothe
createBitbucketMetadatahelper to support them.Verification
No manual run. This is an internal credential-handling guard, covered by unit
tests. Full
session-service.test.tspasses (94 tests), and I confirmed the newtests actually cover the guard: with the guard removed, both contained-path tests
fail because the strip runs (
updateGitRemoteUrlcalled once). Typecheck, lint,and format clean.
Visual Changes
N/A
Reviewer Notes
had no capability check, unlike the wrapper's version.
function only receives
metadata. WhencredentialContainment.bitbucketistrue a capability was issued, so the origin is safe to keep.