{"record":{"id":"49503c6e3af0306e","repo":"gastownhall/beads","slug":"git-ls-remote-s-failed-s-w","errorCode":null,"errorMessage":"git ls-remote %s failed: %s: %w","messagePattern":"git ls-remote (.+?) failed: (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/dolt_remote_reset_data.go","lineNumber":126,"sourceCode":"func resetDataGitURL(url string) string {\n\tif trimmed := strings.TrimPrefix(url, \"git+\"); trimmed != url {\n\t\treturn trimmed\n\t}\n\tif path, isFile := resetDataFilePath(url); isFile && !strings.HasPrefix(url, \"file://\") {\n\t\treturn \"file://\" + path\n\t}\n\treturn url\n}\n\n// lsRemoteDoltDataRefs returns which of the Dolt data-plane refs currently\n// exist on the git remote at gitURL.\nfunc lsRemoteDoltDataRefs(ctx context.Context, gitURL string) ([]string, error) {\n\tctx, cancel := context.WithTimeout(ctx, 60*time.Second)\n\tdefer cancel()\n\tcmd := exec.CommandContext(ctx, \"git\", \"ls-remote\", gitURL, gitDoltDataRef, gitDoltInfoRef) // #nosec G204 -- URL from configured remote\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"git ls-remote %s failed: %s: %w\", gitURL, strings.TrimSpace(string(out)), err)\n\t}\n\tvar refs []string\n\tfor _, line := range strings.Split(strings.TrimSpace(string(out)), \"\\n\") {\n\t\tfields := strings.Fields(line)\n\t\tif len(fields) == 2 {\n\t\t\trefs = append(refs, fields[1])\n\t\t}\n\t}\n\treturn refs, nil\n}\n\n// deleteGitDoltDataRefs deletes refs on the git remote at gitURL. Git\n// client-side hooks are disabled for the push, same as bd's other internal\n// git invocations (GH#3724 class: a user's templated pre-push hook must not\n// break — or observe — bd's data-plane plumbing).\nfunc deleteGitDoltDataRefs(ctx context.Context, gitURL string, refs []string) error {\n\targs := []string{\"push\", gitURL}\n\tfor _, ref := range refs {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/dolt_remote_reset_data.go#L108-L144","documentation":"lsRemoteDoltDataRefs runs 'git ls-remote <url> <dolt-data-ref> <dolt-info-ref>' with a 60-second timeout to discover Dolt data refs on a git-backed remote, and wraps any non-zero exit (including timeout) into this error with the combined stdout/stderr from git. The wrapped output usually contains git's real diagnosis (auth failure, unknown host, no repository).","triggerScenarios":"bd dolt remote reset-data against a git-backed remote where git ls-remote fails: bad URL, missing/invalid credentials, SSH key not loaded, network outage, or the 60s context timeout elapsing on a hung connection.","commonSituations":"CI lacking deploy-key access to the remote; HTTPS remote requiring a token that isn't configured; private remote behind VPN that's down; typo'd remote URL; very slow network exceeding the 60s timeout.","solutions":["Run 'git ls-remote <url>' manually to see the raw git error and fix that (credentials, URL, network)","Ensure credentials are available: configure SSH keys (ssh-add) or a credential helper/token for HTTPS","Confirm the remote URL is correct with git remote -v / bd dolt remote -v","Check network/VPN connectivity; if operations are slow, note the 60-second timeout may need the underlying network fixed rather than retried blindly"],"exampleFix":"// before\nremote = git@host:org/repo.git  # SSH key not loaded -> permission denied\n// after\nssh-add ~/.ssh/id_ed25519 && bd dolt remote reset-data origin","handlingStrategy":"retry","validationCode":"ctx, cancel := context.WithTimeout(ctx, 10*time.Second)\nout, err := exec.CommandContext(ctx, \"git\", \"ls-remote\", url).CombinedOutput()\nif err != nil { return fmt.Errorf(\"pre-flight ls-remote failed: %s\", out) }","typeGuard":null,"tryCatchPattern":"refs, err := lsRemoteDoltDataRefs(ctx, gitURL)\nif err != nil {\n    var netErr error\n    if errors.As(err, &netErr) && ctx.Err() == context.DeadlineExceeded {\n        // retry once after checking connectivity\n    }\n}","preventionTips":["Verify 'git ls-remote <url>' works interactively before scripting reset-data","Load SSH keys (ssh-add) or configure credential helpers in CI","Remember the built-in 60s timeout; fix network latency rather than looping retries"],"tags":["git","network","remote","subprocess","timeout"],"backgroundTag":"git-ls-remote-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}