{"record":{"id":"be3f288fb8863d6e","repo":"gastownhall/beads","slug":"issue-not-found-s-be3f28","errorCode":null,"errorMessage":"issue not found: %s","messagePattern":"issue not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/relate.go","lineNumber":182,"sourceCode":"\t}\n\tid2, err = utils.ResolvePartialID(ctx, store, args[1])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to resolve %s: %w\", args[1], err)\n\t}\n\n\t// Get both issues\n\tvar issue1, issue2 *types.Issue\n\tissue1, err = store.GetIssue(ctx, id1)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get issue %s: %w\", id1, err)\n\t}\n\tissue2, err = store.GetIssue(ctx, id2)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get issue %s: %w\", id2, err)\n\t}\n\n\tif issue1 == nil {\n\t\treturn fmt.Errorf(\"issue not found: %s\", id1)\n\t}\n\tif issue2 == nil {\n\t\treturn fmt.Errorf(\"issue not found: %s\", id2)\n\t}\n\n\t// Remove relates-to dependency in both directions\n\t// Per Decision 004, relates-to links are now stored in dependencies table.\n\t// bd unrelate is an explicit dependency verb, so it records history\n\t// (EmitEvent) like bd dep remove; only structural teardown stays silent.\n\t// Remove id1 -> id2\n\tif err := store.RemoveDependencyWithOptions(ctx, id1, id2, actor, storage.DependencyRemoveOptions{EmitEvent: true}); err != nil {\n\t\treturn fmt.Errorf(\"failed to remove relates-to %s -> %s: %w\", id1, id2, err)\n\t}\n\t// Remove id2 -> id1 (bidirectional)\n\tif err := store.RemoveDependencyWithOptions(ctx, id2, id1, actor, storage.DependencyRemoveOptions{EmitEvent: true}); err != nil {\n\t\treturn fmt.Errorf(\"failed to remove relates-to %s -> %s: %w\", id2, id1, err)\n\t}\n","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/relate.go#L164-L200","documentation":"After GetIssue returns no error, runUnrelate checks whether the first issue came back nil; if so it reports 'issue not found: <id1>'. Beads' storage returns (nil, nil) for a nonexistent issue, so this is the explicit missing-record path rather than a storage failure. bd unrelate requires both endpoints of the relates-to link to exist.","triggerScenarios":"`bd unrelate <id1> <id2>` where id1 does not exist in the store: mistyped or stale issue ID, issue deleted earlier, wrong repository/directory (the ID exists in another .beads database), or an ID from an unsynced remote.","commonSituations":"Copy-pasting IDs from another project's output; the issue was closed and garbage-collected or deleted on another machine and synced away; typos like bd-12 vs bd-112; running in a fresh clone before `bd dolt pull` fetched the issues.","solutions":["Run `bd show <id1>` (or `bd list`) to confirm the ID exists locally; correct typos in the ID.","If the ID lives in another repository, cd into the right repo before running unrelate.","If the issue should exist, sync first: `bd dolt pull` to fetch remote deletions/creations, then re-check.","If the issue was genuinely deleted, the link is already gone — nothing to unrelate; verify with `bd dep <id2>` and proceed without the command.","Use `bd ready`/`bd list` to find the correct current ID rather than relying on memory or old shell history."],"exampleFix":"// before\n$ bd unrelate bd-12 bd-7   # bd-12 never existed (typo for bd-112)\nissue not found: bd-12\n// after\n$ bd unrelate bd-112 bd-7","handlingStrategy":"validation","validationCode":"func requireIssue(ctx context.Context, store storage.Store, id string) error {\n\tissue, err := store.GetIssue(ctx, id)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif issue == nil {\n\t\treturn fmt.Errorf(\"issue %s does not exist locally; run 'bd list' or 'bd dolt pull' first\", id)\n\t}\n\treturn nil\n}","typeGuard":"func issueExists(ctx context.Context, store storage.Store, id string) bool {\n\tissue, err := store.GetIssue(ctx, id)\n\treturn err == nil && issue != nil\n}","tryCatchPattern":null,"preventionTips":["Copy issue IDs from `bd list`/`bd show` output, not from memory or old shell history.","Run `bd dolt pull` before operating in a fresh clone or after teammates delete issues.","Confirm you are in the correct repository — IDs are per-.beads-database.","Check whether an issue was deleted (by a teammate or cleanup job) before assuming a typo."],"tags":["go","cli","unrelate","issue-not-found","ids"],"backgroundTag":"issue-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}