{"record":{"id":"8b8ea56876af80d0","repo":"gastownhall/beads","slug":"failed-to-inspect-configured-upstream-w","errorCode":null,"errorMessage":"failed to inspect configured upstream: %w","messagePattern":"failed to inspect configured upstream: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":1980,"sourceCode":"\tgit *worktreeRemovalGit,\n\texecutionRoot string,\n\ttarget pinnedWorktreeTarget,\n) (pinnedWorktreeComparator, error) {\n\tif target.branch == \"\" || target.detached {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"cannot verify unpushed commits: target is detached; use --merged-into <ref>\",\n\t\t)\n\t}\n\toutput, err := git.output(\n\t\tctx,\n\t\texecutionRoot,\n\t\t\"for-each-ref\",\n\t\t\"--format=%(upstream)\",\n\t\t\"--\",\n\t\ttarget.branch,\n\t)\n\tif err != nil {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\"failed to inspect configured upstream: %w\", err)\n\t}\n\tupstreamRef := strings.TrimSpace(string(output))\n\tif upstreamRef == \"\" || strings.Contains(upstreamRef, \"\\n\") {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"cannot verify unpushed commits: the target branch has no single resolvable upstream; configure an upstream or use --merged-into <ref>\",\n\t\t)\n\t}\n\treturn pinWorktreeComparatorRef(\n\t\tctx,\n\t\tgit,\n\t\texecutionRoot,\n\t\ttarget,\n\t\tupstreamRef,\n\t\tupstreamRef,\n\t\tfalse,\n\t)\n}\n","sourceCodeStart":1962,"sourceCodeEnd":1998,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L1962-L1998","documentation":"This error wraps a failure from `git for-each-ref --format=%(upstream)` used to discover the upstream of the target branch. It also (in the same function) covers the case where the upstream is empty or ambiguous (multiple lines). The library needs exactly one resolvable upstream to compute unpushed commits; if the git query fails or the branch has none, it reports this wrapped error or the follow-up 'no single resolvable upstream' error.","triggerScenarios":"Calling the pinned-worktree comparison flow when (a) the underlying `git for-each-ref` command fails (corrupt repo, bad ref, git not found), or (b) `target.branch` has no configured upstream (`branch.<name>.remote` unset), or the format resolves to multiple/ambiguous upstream entries.","commonSituations":"Locally created branches never pushed (`git push -u` never run); branches pushed via explicit `git push origin <branch>` without setting upstream; shallow/CI clones with limited ref configuration; renamed branches whose upstream config was lost.","solutions":["Set an upstream for the branch: `git push -u origin <branch>` (or `git branch --set-upstream-to=origin/<branch> <branch>`).","Bypass upstream detection by passing --merged-into <ref> with an explicit comparison reference.","Inspect `git config branch.<name>.remote` / `git config branch.<name>.merge` and fix the branch configuration if it points at a deleted remote."],"exampleFix":"// before\ngit push origin feature-x   # upstream not configured -> error\n// after\ngit push -u origin feature-x","handlingStrategy":"validation","validationCode":"upstream, _ := execGit(\"git\", \"rev-parse\", \"--abbrev-ref\", \"--symbolic-full-name\", \"@{u}\")\nif strings.TrimSpace(upstream) == \"\" {\n    // no upstream configured: set one or use --merged-into\n    execGit(\"git\", \"push\", \"-u\", \"origin\", branch)\n}","typeGuard":null,"tryCatchPattern":"out, err := runWorktreeVerify(...)\nif err != nil && strings.Contains(err.Error(), \"failed to inspect configured upstream\") {\n    return runWorktreeVerify(..., \"--merged-into\", \"main\")\n}","preventionTips":["Always push new branches with `git push -u` so upstream is configured from the start.","Run `git branch -vv` in preflight checks to flag branches without upstreams.","Prefer explicit --merged-into in non-interactive scripts over relying on upstream config.","After renaming or recreating branches, re-run `git branch --set-upstream-to`."],"tags":["git","worktree","upstream","branch-configuration"],"backgroundTag":"missing-git-upstream","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}