Skip to content

fix: pass original URL with credentials to sync_refs for private repos#4483

Open
octo-patch wants to merge 1 commit intoTabbyML:mainfrom
octo-patch:fix/git-credentials-stripped-in-url
Open

fix: pass original URL with credentials to sync_refs for private repos#4483
octo-patch wants to merge 1 commit intoTabbyML:mainfrom
octo-patch:fix/git-credentials-stripped-in-url

Conversation

@octo-patch
Copy link
Copy Markdown

Problem

Private repositories configured with authentication credentials in the URL (e.g. Bitbucket, GitLab repositories in subgroups) fail to clone or pull with errors like:

fatal: could not read Username for 'https://bitbucket.org': No such device or address

The root cause is in CodeRepository::sync() — it calls self.canonical_git_url() which strips the username and password from the URL before passing it to sync_refs(). So the git clone/pull command runs without credentials.

Fixes #4434, closes #4431.

Changes

crates/tabby-index/src/code/repository.rs

  • Pass self.git_url (original URL with credentials) to sync_refs instead of self.canonical_git_url().

crates/tabby-git/src/lib.rs

  • Add mask_url_credentials() helper that strips credentials for safe log output.
  • Update log/error messages in sync_refs to use the masked URL so credentials are never exposed in logs.
  • For existing clones (else branch), call git remote set-url origin <url> so credential changes in the config take effect without a full re-clone.

Testing

The directory name for cloned repos is derived from the canonical URL (no credentials), which is correct — this ensures the directory stays stable even when credentials change. The fix ensures only the git commands receive the full URL with credentials while logs always see the masked version.

Private repositories authenticated via URL (e.g. Bitbucket, GitLab subgroups)
were silently losing their credentials before the git clone/pull command ran.
`CodeRepository::sync()` was calling `self.canonical_git_url()` which strips
the username and password, causing git to fail with
"could not read Username ... No such device or address".

- In `tabby-index`: pass `self.git_url` (original URL) to `sync_refs` instead
  of the credential-stripped `canonical_git_url()`.
- In `tabby-git`: add `mask_url_credentials()` helper to safely redact
  credentials in log output, and call `git remote set-url` on existing clones
  so credential changes in config take effect without a full re-clone.

Fixes TabbyML#4434, TabbyML#4431
@wsxiaoys wsxiaoys requested a review from liangfung April 23, 2026 06:32
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.

Unable to connect to bitbucket repo GitLab context pull fails for repositories in subgroups

1 participant