Skip to content

fix(bitbucket): bind cursors and task locations case-insensitively - #6883

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/bitbucket-case-insensitive-binding
Aug 20, 2026
Merged

fix(bitbucket): bind cursors and task locations case-insensitively#6883
waleedlatif1 merged 2 commits into
stagingfrom
fix/bitbucket-case-insensitive-binding

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Follow-up to #6860, which merged before this round of review feedback landed.

Cursor Bugbot flagged this on #6860 (thread r3818428661) after the squash merge, so the fix goes up separately.

Problem

Bitbucket resolves workspace and repository slugs case-insensitively but echoes the canonical lowercase form back in next links, diff/diffstat redirect targets, and async merge task Location headers. Three call sites bound those responses back to the caller's slug with exact string equality, so a mixed-case workspaceSlug or repoSlug succeeded on the first request and then threw on every follow-up:

  • pagination broke on the second page
  • PR diff/diffstat redirect resolution failed
  • merge task polling failed after a 202 — the worst case, since the merge has already started by then

Fix

All three now compare through a shared equalsIgnoreCase:

Site Scope of the change
bitbucketApiUrl exact-path branch, nextPathPrefix segment match, and nextRevision (hex SHAs are case-insensitive, and requireBitbucketSha1 already accepts uppercase)
validateBitbucketPullRequestRedirect prefix match only — the opaque spec after it is still sliced from the original pathname verbatim
mergeTaskLocation same, with the task id decoded from the untouched pathname

Repository file paths keep verbatim comparison — git treats those as case-sensitive, so src/Dir must not match src/dir.

Tests

Three cases added, each verified to fail without the fix:

  • a canonical-cased cursor accepted for a mixed-case slug (utils.test.ts)
  • a re-cased file path still rejected (utils.test.ts)
  • a canonical-cased merge task Location accepted for a mixed-case slug (pull-requests.test.ts)

The same bug class was fixed in the repository selector route in #6860; this closes it in the tool layer.

Bitbucket resolves workspace and repository slugs case-insensitively but echoes
the canonical lowercase form in `next` links, diff/diffstat redirect targets, and
async merge task Locations. Binding those back with exact string equality meant a
mixed-case slug succeeded on the first request and then failed on every follow-up
— worst on a 202 merge, where the merge has already started when polling breaks.

Repository file paths keep verbatim comparison; git treats those as case-sensitive.
@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 20, 2026 3:49am

Request Review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@cursor

cursor Bot commented Aug 20, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Targeted validation fix in the Bitbucket tool layer with tests; no auth or broad behavioral changes beyond accepting canonical-cased slugs Bitbucket already returns.

Overview
Bitbucket returns lowercase workspace/repo slugs in pagination next URLs, PR diff/diffstat redirects, and async merge Location headers even when the caller used mixed case. This PR adds shared equalsIgnoreCase and uses it wherever those responses are validated against the caller’s slugs (and commit SHAs), so follow-up requests no longer fail after a successful first call.

bitbucketApiUrl now case-insensitively matches list cursors and revision segments; repository file path segments after the revision stay case-sensitive. validateBitbucketPullRequestRedirect and mergeTaskLocation use the same rule for URL prefix checks.

Tests cover mixed-case slugs with canonical URLs and confirm re-cased directory paths are still rejected.

Reviewed by Cursor Bugbot for commit 13f260d. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This follow-up narrows Bitbucket path comparison so only workspace and repository slug segments are case-insensitive while fixed endpoint and repository-path segments remain exact.

  • Applies the shared segment-aware comparison to pagination cursors, pull-request redirects, and asynchronous merge task locations.
  • Adds regressions for canonicalized mixed-case slugs and rejection of re-cased fixed or file-path segments.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/tools/bitbucket/utils.ts Introduces segment-aware path comparison that folds only workspace and repository slugs while preserving exact matching for fixed endpoints and file paths.
apps/sim/tools/bitbucket/merge_pull_request.ts Uses the shared repository-prefix matcher to accept Bitbucket-canonicalized slug casing in merge task locations.
apps/sim/tools/bitbucket/utils.test.ts Covers mixed-case slug acceptance and exact-case enforcement for fixed endpoint and repository file-path segments.
apps/sim/tools/bitbucket/pull-requests.test.ts Verifies canonicalized merge task locations remain bound to mixed-case caller slugs.

Reviews (2): Last reviewed commit: "fix(bitbucket): fold only the slug segme..." | Re-trigger Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 13f260d. Configure here.

Comment thread apps/sim/tools/bitbucket/utils.ts Outdated
Segment-wise comparison replaces whole-path case folding, so a cursor that recases
a fixed endpoint literal (repositories, commits, pullrequests) fails locally again
instead of being deferred to Bitbucket. Only the workspace and repository segments
of a /2.0/repositories path fold; file paths and literals stay verbatim.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ecb5ba8. Configure here.

@waleedlatif1
waleedlatif1 merged commit 4fce519 into staging Aug 20, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/bitbucket-case-insensitive-binding branch August 20, 2026 05:34
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