{"record":{"id":"db014f2189bdbc31","repo":"gastownhall/beads","slug":"replacement-issue-not-found-s","errorCode":null,"errorMessage":"replacement issue not found: %s","messagePattern":"replacement issue not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/duplicate.go","lineNumber":167,"sourceCode":"\tvar err error\n\toldID, err = utils.ResolvePartialID(ctx, store, args[0])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to resolve %s: %w\", args[0], err)\n\t}\n\tnewID, err = utils.ResolvePartialID(ctx, store, supersededWith)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to resolve %s: %w\", supersededWith, err)\n\t}\n\n\tif oldID == newID {\n\t\treturn fmt.Errorf(\"cannot mark an issue as superseded by itself\")\n\t}\n\n\t// Verify new issue exists\n\tvar newIssue *types.Issue\n\tnewIssue, err = store.GetIssue(ctx, newID)\n\tif err != nil || newIssue == nil {\n\t\treturn fmt.Errorf(\"replacement issue not found: %s\", newID)\n\t}\n\n\t// Add a \"supersedes\" dependency edge (old → new)\n\tdep := &types.Dependency{\n\t\tIssueID:     oldID,\n\t\tDependsOnID: newID,\n\t\tType:        types.DepSupersedes,\n\t}\n\tif err := store.AddDependency(ctx, dep, actor); err != nil {\n\t\treturn fmt.Errorf(\"failed to add supersede link: %w\", err)\n\t}\n\n\t// Close the superseded issue through the lifecycle operation so it records\n\t// the complete closure state.\n\tif err := store.CloseIssue(ctx, oldID, \"\", actor, \"\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to close superseded issue: %w\", err)\n\t}\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/duplicate.go#L149-L185","documentation":"runSupersede resolves the replacement issue via store.GetIssue before wiring a supersedes dependency. When GetIssue returns an error or a nil issue, the command aborts so it never creates a supersede edge pointing at a nonexistent issue. This protects the dependency graph from dangling references.","triggerScenarios":"Running `bd supersede OLD NEW` where NEW does not exist in the store, NEW was deleted, the ID is misspelled or from another database, or GetIssue fails on a transient storage error (including err==nil with nil issue).","commonSituations":"Typo in the replacement issue ID; replacing across two separate beads databases; the replacement issue was closed-and-deleted by a cleanup/prune job; stale Dolt sync left the local DB without the issue.","solutions":["Verify the replacement ID with `bd show <newID>` before running supersede","Run `bd dolt pull` / re-sync so the replacement issue exists locally","Check you are in the repo/directory backed by the intended beads database","Create the replacement issue first with `bd create` if it does not exist yet"],"exampleFix":"// before\nnewIssue, err = store.GetIssue(ctx, newID)\n// after\n// ensure the replacement exists (and surface the real storage error)\nnewIssue, err = store.GetIssue(ctx, newID)\nif err != nil { return fmt.Errorf(\"lookup replacement %s: %w\", newID, err) }\nif newIssue == nil { return fmt.Errorf(\"replacement issue not found: %s (run `bd show %s` to verify)\", newID, newID) }","handlingStrategy":"validation","validationCode":"// before supersede\nif out, err := exec.Command(\"bd\", \"show\", newID).CombinedOutput(); err != nil {\n    return fmt.Errorf(\"replacement %s does not exist: %s\", newID, out)\n}","typeGuard":null,"tryCatchPattern":"if err := runSupersede(ctx, oldID, newID); err != nil {\n    if strings.Contains(err.Error(), \"replacement issue not found\") {\n        // correct the ID / create the issue, then retry\n    }\n}","preventionTips":["Copy issue IDs from `bd show`/`bd list` output instead of typing them","Confirm both issues live in the same beads database before superseding","Sync (`bd dolt pull`) before cross-session lifecycle operations"],"tags":["cli","issue-tracking","supersede"],"backgroundTag":"issue-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}