{"record":{"id":"9deeb41a7ee8e8b5","repo":"gastownhall/beads","slug":"canonical-issue-not-found-s","errorCode":null,"errorMessage":"canonical issue not found: %s","messagePattern":"canonical issue not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/duplicate.go","lineNumber":97,"sourceCode":"\tvar err error\n\tduplicateID, 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\tcanonicalID, err = utils.ResolvePartialID(ctx, store, duplicateOf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to resolve %s: %w\", duplicateOf, err)\n\t}\n\n\tif duplicateID == canonicalID {\n\t\treturn fmt.Errorf(\"cannot mark an issue as duplicate of itself\")\n\t}\n\n\t// Verify canonical issue exists\n\tvar canonical *types.Issue\n\tcanonical, err = store.GetIssue(ctx, canonicalID)\n\tif err != nil || canonical == nil {\n\t\treturn fmt.Errorf(\"canonical issue not found: %s\", canonicalID)\n\t}\n\n\t// Add a \"duplicates\" dependency edge (duplicate → canonical)\n\tdep := &types.Dependency{\n\t\tIssueID:     duplicateID,\n\t\tDependsOnID: canonicalID,\n\t\tType:        types.DepDuplicates,\n\t}\n\tif err := store.AddDependency(ctx, dep, actor); err != nil {\n\t\treturn fmt.Errorf(\"failed to add duplicate link: %w\", err)\n\t}\n\n\t// Close the duplicate issue through the lifecycle operation so it records\n\t// the complete closure state.\n\tif err := store.CloseIssue(ctx, duplicateID, \"\", actor, \"\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to close duplicate: %w\", err)\n\t}\n","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/duplicate.go#L79-L115","documentation":"Raised when store.GetIssue returns an error or nil for the resolved canonical ID in runDuplicate — the canonical issue could not be loaded from the store even though its ID resolved. This catches races (issue deleted between resolve and fetch) and storage read failures, and is reported with the canonical ID. The duplicate is left unmodified.","triggerScenarios":"The canonical issue was deleted or closed/purged between ResolvePartialID and GetIssue; the underlying Dolt/driver read fails; a nil row is returned for the resolved ID.","commonSituations":"Concurrent deletion by another agent or process in a multi-agent workflow; a stale replica out of sync; storage corruption or driver error surfacing as a GetIssue failure.","solutions":["Re-run `bd show <canonical-id>` to check the issue still exists","Re-run the duplicate command — a transient storage error may have cleared","Run `bd doctor` / verify store integrity if GetIssue keeps failing","Pick a different canonical issue if the target was deleted"],"exampleFix":"// before\n$ bd duplicate bd-42 --duplicate-of bd-99  # bd-99 deleted moments ago\nError: canonical issue not found: bd-99\n// after\n$ bd list | grep bd-  # pick an existing canonical\n$ bd duplicate bd-42 --duplicate-of bd-101","handlingStrategy":"validation","validationCode":"canonical, err := store.GetIssue(ctx, canonicalID)\nif err != nil || canonical == nil {\n    return fmt.Errorf(\"canonical %s missing; pick another with bd list\", canonicalID)\n}","typeGuard":"if canonical == nil {\n    return fmt.Errorf(\"canonical issue %s does not exist\", canonicalID)\n}","tryCatchPattern":"canonical, err := store.GetIssue(ctx, canonicalID)\nif err != nil {\n    if errors.Is(err, ErrKeyNotFound) { return fmt.Errorf(\"canonical %s deleted\", canonicalID) }\n    return fmt.Errorf(\"storage error fetching canonical: %w\", err)\n}","preventionTips":["Re-verify the canonical issue immediately before marking duplicates","Avoid deleting issues concurrently with duplicate-marking in multi-agent setups"],"tags":["cli","storage","duplicate"],"backgroundTag":"issue-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}