Skip to content

Worktree setup hides malformed local Git refs behind a generic fetch error #38779

Closed

Description

@mikebanks

What happened

Two T3 workers on my Mac stopped at Fetch base branch before either agent started. The message said git fetch origin failed. Running the fetch directly named the invalid local ref, which was the detail I needed to tell what happened.

Diagnosis

On Nightly 4890, the scoped fetch in GitVcsDriver.fetchRemote uses fetchFailureDetail to classify stderr and otherwise falls back to the generic message. The classifier has no case for fatal: bad object refs/.... The same gap is present on current main. Please show a fixed message such as “Git found a broken local ref. Check the local repository before retrying.” If the ref is shown, validate and bound it. Preserve the existing protection against persisting raw Git stderr, which can contain credentials.

Source:

// Fetch stderr can carry credentials; persist only fixed diagnoses or generic failures.
function fetchFailureDetail(stderr: string): string | undefined {
const lines = stderr.split(/\r?\n/).map((line) => line.trim());
if (
lines.some((line) =>
/^(?:fatal: (?:Authentication failed|could not read (?:Username|Password))\b|\S+: Permission denied \(publickey)/i.test(
line,
),
)
) {
return "Git could not authenticate with the remote. Check Git credentials or SSH access on the server, then retry.";
}
if (
lines.some((line) =>
/^(?:(?:fatal: |ssh: )?Could not resolve host(?:name)?\b|fatal: unable to access .+: (?:Could not resolve host|Failed to connect)\b|ssh: connect to host \S+ port \d+: (?:Connection timed out|Connection refused|Network is unreachable)\b)/i.test(
line,
),
)
) {
return "Git could not reach the remote. Check the server's network connection and remote host, then retry.";
}
if (
lines.some((line) =>
/^(?:remote: Repository not found\.?$|fatal: repository .+ not found$|fatal: .+ does not appear to be a git repository$)/i.test(
line,
),
)
) {
return "Git could not access the remote repository. Check the remote URL and repository permissions on the server.";
}
if (isRefLockFailure(stderr)) {
return "Git could not update a local reference. Another Git operation or a stale lock may be blocking the fetch; check the repository on the server, then retry.";
}
return undefined;
}
// Git 2.53+ reports ref races as fetching-ref failures; older versions say cannot lock ref.
function isRefLockFailure(stderr: string): boolean {
return stderr
.split(/\r?\n/)
.some((line) =>

Steps to reproduce

  1. Make a disposable clone with origin/dev. Advance the remote branch by one commit, leaving the clone behind.
  2. In the clone, run git rev-parse refs/remotes/origin/dev > '.git/refs/remotes/origin/dev 2' to model the numbered file found on the affected Mac.
  3. In T3, create a worktree from origin/dev with Start from origin. For the Git-only check, run git fetch --dry-run --no-tags -- origin +refs/heads/dev:refs/remotes/origin/dev from the clone.

Version

0.1.11-nightly.20261118.4890 (desktop and local server)

Environment

macOS 27.3 (26C5047e), arm64; Apple Git 2.54.0 (Apple Git-157); local T3 desktop server on the Mac.

Evidence

Two affected launches on November 18, 2026. T3 trace: `GitVcsDriver.fetchRemote: git fetch origin failed`. The source checkout's Git fetch named a local ref ending in ` 2`. The disposable Git repro returned exit 0 with clean refs, exit 1 with `fatal: bad object refs/remotes/origin/dev 2` after adding the fixture, and exit 0 again after removing it. GitHub was reachable from the affected Mac.

Related issues

#10179 requested better fetch diagnostics for an SSH credential failure. #10905 concerned a checkpoint writer leaving an empty ref. This report covers the missing diagnostic for an already-malformed local ref during worktree setup.

Fix applied or workaround

Point T3 at a healthy clone. On the same Mac, the replacement worker prepared its worktree and started successfully from a separate clone outside iCloud Documents.

Filed by

Codex (GPT-6.2 Sol) via t3 triage

Activity

  1. added
    via-triage
    on Nov 18, 2026
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

    via-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions