Skip to content

fix: update Bitbucket clone auth to use API token scheme#509

Merged
sng-asyncfunc merged 2 commits intoAsyncFuncAI:mainfrom
octo-patch:fix/issue-444-bitbucket-api-token-auth
Apr 21, 2026
Merged

fix: update Bitbucket clone auth to use API token scheme#509
sng-asyncfunc merged 2 commits intoAsyncFuncAI:mainfrom
octo-patch:fix/issue-444-bitbucket-api-token-auth

Conversation

@octo-patch
Copy link
Copy Markdown
Contributor

Fixes #444

Problem

When cloning private Bitbucket repositories, the application uses the x-token-auth authentication 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 the x-bitbucket-api-token-auth scheme 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.py line 120):

# Before (broken for API tokens):
clone_url = urlunparse((parsed.scheme, f"x-token-auth:{encoded_token}@{parsed.netloc}", ...))

# After (works with current Bitbucket HTTP access tokens):
clone_url = urlunparse((parsed.scheme, f"x-bitbucket-api-token-auth:{encoded_token}@{parsed.netloc}", ...))

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-auth is the correct scheme per Atlassian's documentation for HTTP access tokens.

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
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread api/data_pipeline.py Outdated
Comment on lines +119 to +123
# 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, '', '', ''))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
# 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.
@octo-patch
Copy link
Copy Markdown
Contributor Author

Thanks @gemini-code-assist! You're right — that was a regression for App Password users.

Pushed ae9d45c which detects the token format by its ATCTT prefix and picks the matching auth scheme: x-bitbucket-api-token-auth for HTTP access tokens, x-token-auth for App Passwords (still supported until June 2026).

@gemini-code-assist
Copy link
Copy Markdown
Contributor

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.

@sng-asyncfunc sng-asyncfunc merged commit e8b6f1e into AsyncFuncAI:main Apr 21, 2026
2 checks passed
RichelynScott added a commit to RichelynScott/deepwiki-open that referenced this pull request Apr 26, 2026
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>
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.

Error fetching repo from private bitbucket repo, outdated auth method

2 participants