Skip to content

Machine GitHub credential forwarding clears local GitLab HTTPS helpers #8048

Description

@gaodes

Summary

With machine Git credentials enabled, Git operations on an enrolled non-primary machine lose local credential helpers for non-GitHub repositories. The forwarded GitHub helper works, but a private GitLab HTTPS fetch fails even though the machine has a working GitLab helper.

Versions and environment

  • bb 0.50.1, npm server install; Linux primary server and enrolled macOS worktree host.
  • Git 2.55.0. Reproduced on the enrolled host; the primary host does not receive the injected Git config.
  • The same config entries are present on upstream main at a89f5d7, lines 12–15. I did not run a bb build from main.

Steps to reproduce

  1. Enable machine Git credentials and sign in to GitHub on the bb server. Enroll a second machine.
  2. On that machine, configure a working helper for a private GitLab HTTPS repository.
  3. In a bb worktree thread on the enrolled machine, run GIT_TERMINAL_PROMPT=0 git ls-remote <private-gitlab-https-url> HEAD.
  4. In the same thread, repeat with env -u GIT_CONFIG_COUNT GIT_TERMINAL_PROMPT=0 git ls-remote <private-gitlab-https-url> HEAD. This is a diagnostic control, not a fix.

Expected vs actual

Expected: GitHub uses the forwarded helper and GitLab can still use the machine's helper. Actual: GitHub succeeds, GitLab exits 128 with fatal: could not read Username. The diagnostic control succeeds for GitLab.

Evidence and proposed patch

In githubGitConfiguration, use credential.https://github.com.helper for both helper keys. Keep the empty reset first and the forwarded helper second. Do not change either GitHub SSH-to-HTTPS rewrite.

The investigation report is the self-contained fixture below. Save it as repro.sh and run sh repro.sh. It uses command-scope config (like bb), synthetic credentials, and no network.

#!/bin/sh
set -eu
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
cd "$scratch"
chmod 700 "$scratch"
cat > gitconfig <<'EOF'
[credential "https://gitlab.example"]
    helper = "!f() { printf 'username=local-gitlab\\npassword=synthetic\\n'; }; f"
[credential "https://github.com"]
    helper = "!f() { printf 'username=local-github\\npassword=synthetic\\n'; }; f"
EOF
forwarded='!f() { if grep -qx host=github.com; then printf "username=forwarded-github\npassword=synthetic\n"; fi; }; f'
probe() {
    scope=$1 host=$2
    result=$(printf 'protocol=https\nhost=%s\n\n' "$host" |
        env -i PATH="$PATH" HOME="$scratch" GIT_CONFIG_NOSYSTEM=1 \
        GIT_CONFIG_GLOBAL="$scratch/gitconfig" GIT_TERMINAL_PROMPT=0 \
        git -c "$scope=" -c "$scope=$forwarded" credential fill 2>&1) || {
            printf '%s | %s | %s\n' "$scope" "$host" "$result"
            return
        }
    printf '%s | %s | %s\n' "$scope" "$host" "$(printf '%s\n' "$result" | grep '^username=')"
}
probe credential.helper gitlab.example
probe credential.https://github.com.helper gitlab.example
probe credential.https://github.com.helper github.com

Observed with Git 2.55.0:

credential.helper | gitlab.example | fatal: could not read Username for 'https://gitlab.example': terminal prompts disabled
credential.https://github.com.helper | gitlab.example | username=local-gitlab
credential.https://github.com.helper | github.com | username=forwarded-github

A one-shot test with the two proposed keys also succeeded against real GitLab and GitHub HTTPS remotes on the enrolled machine. No persistent config was changed.

What you ruled out

AGENT GENERATED

Activity

  1. added theissue type on Nov 23, 2026
  2. added
    workspaces
    host
    confirmed-repro
    on Nov 23, 2026
  3. bb-slop-cop commented on Nov 23, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low · Areas: workspaces, host.
    • Report: https://get-bb.github.io/reports/issues/8048.html
    • Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro.
    • Root cause: bb's unscoped command-environment helper reset clears unrelated local credential helpers; its replacement only answers HTTPS GitHub requests.
    • Verification: reproduced twice against trusted main in separate clean checkouts using real Git and synthetic credentials. The focused preservation assertion fails; GitHub forwarding controls and 11 existing tests pass. Live macOS/private-remote access was not tested.
    • No PR: the repair changes credential-selection/authentication behavior, which this rule excludes from automatic simple fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reprohostworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions