Skip to content

Conversation

@aft
Copy link

@aft aft commented Nov 18, 2025

Problem

Bitbucket Cloud repository cloning was failing with authentication errors. The root cause was a mismatch between the credential formats required by different Bitbucket operations:

  • Bitbucket API calls require the full email address (e.g., user@example.com)
  • Git clone operations require only the username portion (e.g., user)

Previously, the code was passing the full email address to git clone URLs, causing authentication failures like:

fatal: Authentication failed for 'https://bitbucket.org/workspace/repo.git'

Solution

Extract the username from the configured email address when building git clone URLs for Bitbucket repositories. The fix uses JavaScript's split('@')[0] to extract the username portion while maintaining the full email for API authentication.

The getAuthCredentialsForRepo function in utils.ts was updated to handle Bitbucket's specific authentication requirements:

  1. The full email from config.user is preserved for API operations
  2. Only the username portion is used when constructing the cloneUrlWithToken
  3. The username is passed to createGitCloneUrlWithToken which builds the authenticated URL format: https://username:token@bitbucket.org/...

Testing

  • ✅ Verified with Bitbucket Cloud repositories
  • ✅ Confirmed successful authentication and repository cloning

Related Issues

Fixes #573 - Sourcebot not indexing branches for bitbucket


Note

Fixes Bitbucket clone authentication by aligning credential formats.

  • Updates getAuthCredentialsForRepo to derive username from config.user.split('@')[0] for Bitbucket when constructing cloneUrlWithToken
  • Preserves full email for API operations; only the git clone URL now uses the username portion

Written by Cursor Bugbot for commit dd8492a. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@aft aft marked this pull request as ready for review November 18, 2025 21:26
@brendan-kellam
Copy link
Contributor

To sanity check, will this break Bitbucket server?

const username = config.user ?? 'x-token-auth';
// Extract username from email if present (e.g., user@example.com -> user)
// Bitbucket API auth uses the full email, but git clone needs just the username
const username = config.user
Copy link
Contributor

@brendan-kellam brendan-kellam Nov 24, 2025

Choose a reason for hiding this comment

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

To my other comment, I'm not sure if this will break bitbucket server. Might be best to only do this if config.deploymentType is cloud

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, but I can’t confirm whether it breaks Bitbucket Server or not. I only have access to Cloud.

If no one can verify it, making it conditional might be better.

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.

[bug] Sourcebot not indexing branches for bitbucket

2 participants