{"record":{"id":"132acbdfd9549da9","repo":"gastownhall/beads","slug":"cannot-mark-an-issue-as-superseded-by-itself","errorCode":null,"errorMessage":"cannot mark an issue as superseded by itself","messagePattern":"cannot mark an issue as superseded by itself","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/duplicate.go","lineNumber":160,"sourceCode":"\n\tctx := getRootContext()\n\tstore := getStore()\n\tactor := getActor()\n\n\t// Resolve partial IDs\n\tvar oldID, newID string\n\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}","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/duplicate.go#L142-L178","documentation":"Self-supersede guard in runSupersede: after resolution, oldID equals newID, so an issue cannot be superseded by itself. Raised before any store mutation, preventing a degenerate supersede relationship and possible lifecycle loops.","triggerScenarios":"`bd supersede bd-42 --superseded-with bd-42`, or two different prefixes that both resolve to the same issue (e.g. bd-4 and bd-42 when only bd-42 exists).","commonSituations":"Accidentally passing the same ID twice; short prefixes resolving to the same issue; scripted commands reusing one variable for both arguments.","solutions":["Create or identify a genuinely different replacement issue and pass its ID","Use sufficiently long prefixes so both arguments resolve to distinct issues","If no replacement exists, don't run supersede — close the old issue instead"],"exampleFix":"// before\n$ bd supersede bd-42 --superseded-with bd-4\nError: cannot mark an issue as superseded by itself\n// after\n$ bd supersede bd-42 --superseded-with bd-101","handlingStrategy":"validation","validationCode":"if oldID == newID {\n    return errors.New(\"old and replacement issues must differ\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use long, unambiguous prefixes so both arguments resolve distinctly","Assert argument inequality in scripts wrapping bd supersede","Create a genuinely new issue instead of re-pointing an issue at itself"],"tags":["cli","validation","supersede"],"backgroundTag":"self-referential-id-rejected","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}