fix: update Bitbucket clone auth to use API token scheme#509
Conversation
Bitbucket is deprecating app passwords (EOL June 2026) and new users can no longer create them. The current code uses the `x-token-auth` scheme, which only works for app passwords. Bitbucket HTTP access tokens require the `x-bitbucket-api-token-auth` scheme. Update the clone URL format for Bitbucket repositories to use `x-bitbucket-api-token-auth`, which is compatible with the current Bitbucket API token authentication method. Fixes AsyncFuncAI#444
There was a problem hiding this comment.
Code Review
This pull request updates the Bitbucket authentication scheme to x-bitbucket-api-token-auth to support modern HTTP access tokens. The reviewer noted that this change is breaking for users of App Passwords, which are supported until 2026, and suggested dynamically selecting the scheme based on the token prefix to ensure backward compatibility.
| # Format: https://x-bitbucket-api-token-auth:{token}@bitbucket.org/owner/repo.git | ||
| # Bitbucket HTTP access tokens require the x-bitbucket-api-token-auth scheme. | ||
| # The older x-token-auth scheme was used for app passwords, which are being | ||
| # deprecated by Atlassian (EOL June 2026). | ||
| clone_url = urlunparse((parsed.scheme, f"x-bitbucket-api-token-auth:{encoded_token}@{parsed.netloc}", parsed.path, '', '', '')) |
There was a problem hiding this comment.
While switching to x-bitbucket-api-token-auth is necessary for the new Bitbucket HTTP access tokens, this change is a breaking one for users still using Bitbucket App Passwords (which require the x-token-auth scheme). Since App Passwords are not fully EOL until June 2026, it would be better to support both schemes to avoid regressions for existing users.
Bitbucket HTTP access tokens can be identified by their ATCTT prefix. We can use this to dynamically select the correct authentication scheme.
| # Format: https://x-bitbucket-api-token-auth:{token}@bitbucket.org/owner/repo.git | |
| # Bitbucket HTTP access tokens require the x-bitbucket-api-token-auth scheme. | |
| # The older x-token-auth scheme was used for app passwords, which are being | |
| # deprecated by Atlassian (EOL June 2026). | |
| clone_url = urlunparse((parsed.scheme, f"x-bitbucket-api-token-auth:{encoded_token}@{parsed.netloc}", parsed.path, '', '', '')) | |
| # Bitbucket HTTP access tokens (starting with 'ATCTT') require x-bitbucket-api-token-auth. | |
| # App passwords (deprecated but supported until June 2026) use x-token-auth. | |
| auth_scheme = "x-bitbucket-api-token-auth" if access_token.startswith("ATCTT") else "x-token-auth" | |
| clone_url = urlunparse((parsed.scheme, f"{auth_scheme}:{encoded_token}@{parsed.netloc}", parsed.path, '', '', '')) |
Bitbucket app passwords are still supported until June 2026 and use the x-token-auth scheme. The earlier patch hard-coded x-bitbucket-api-token-auth which broke existing app-password users. Detect the new HTTP access token format by its 'ATCTT' prefix and pick the matching scheme; fall back to x-token-auth for everything else.
|
Thanks @gemini-code-assist! You're right — that was a regression for App Password users. Pushed ae9d45c which detects the token format by its |
|
That looks like a solid approach to handle the transition while maintaining backward compatibility for existing App Password users. The prefix-based detection is a clean way to distinguish between the two authentication schemes. |
CLAUDE.md cited 4c6a1f7 as the pin but local main is 3 commits past it (includes the LaTeX PR AsyncFuncAI#499 merged 2026-04-23 at 05591ee). Updated effective merge point + listed the 2 unmerged upstream commits with verdicts: - e8b6f1e Bitbucket clone auth fix (AsyncFuncAI#509) — low value for us - 5b43df5 "Deepwiki is coming back" — non-functional Cadence note: ~4 commits / 6 weeks (active but slow). Added drift-check oneliner so future sessions can verify in 2s. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Fixes #444
Problem
When cloning private Bitbucket repositories, the application uses the
x-token-authauthentication scheme (designed for Bitbucket app passwords). However, Bitbucket is deprecating app passwords (EOL June 2026) and has already removed the ability to create new ones from the normal user panel. New users can only generate HTTP access tokens, which require thex-bitbucket-api-token-authscheme instead.This mismatch causes authentication to fail with a 401 error even when the token is valid and can be used to clone the repository manually.
Relevant code (
api/data_pipeline.pyline 120):Solution
Updated the Bitbucket clone URL format to use
x-bitbucket-api-token-auth, the authentication scheme required by Bitbucket HTTP access tokens.Testing
Confirmed that
x-bitbucket-api-token-authis the correct scheme per Atlassian's documentation for HTTP access tokens.