{"record":{"id":"af605a109474a490","repo":"gastownhall/beads","slug":"failed-to-add-supersede-link-w","errorCode":null,"errorMessage":"failed to add supersede link: %w","messagePattern":"failed to add supersede link: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/duplicate.go","lineNumber":177,"sourceCode":"\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\n\tcommandDidWrite.Store(true)\n\n\tif isJSONOutput() {\n\t\treturn outputJSON(map[string]interface{}{\n\t\t\t\"superseded\":  oldID,\n\t\t\t\"replacement\": newID,\n\t\t\t\"status\":      \"closed\",\n\t\t})\n\t}\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/duplicate.go#L159-L195","documentation":"After validating the replacement, runSupersede inserts a DepSupersedes dependency edge (old -> new) via store.AddDependency. Any storage-layer failure is wrapped with this message so the caller knows the supersede link — not the issue lookup or the close step — failed. The command aborts before closing the old issue, leaving both issues open.","triggerScenarios":"AddDependency returns an error: duplicate/self-referential dependency rejected, dependency cycle detected, store not initialized, or an underlying Dolt/driver write error during the transaction.","commonSituations":"Superseding an issue that already depends on the replacement (cycle or duplicate edge); database locked by another writer; write attempted in read-only or server-unreachable mode.","solutions":["Read the wrapped %w cause to identify the storage error","Check the dependency does not already exist (`bd deps <oldID>` / `bd blocked-by`)","Re-run the command after resolving the transient DB condition; AddDependency failure means the old issue was NOT closed, so re-running is safe","Run `bd doctor` to diagnose database connectivity"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"deps, _ := runBdOutput(\"deps\", oldID) // ensure no conflicting supersedes edge exists yet","typeGuard":null,"tryCatchPattern":"if err := runSupersede(ctx, oldID, newID, actor); err != nil {\n    var wrapped interface{ Unwrap() error }\n    if errors.As(err, &target) { /* inspect storage cause */ }\n    log.Warnw(\"supersede link failed; old issue left open\", \"err\", err)\n}","preventionTips":["Check existing dependencies with `bd deps <id>` before adding a supersedes edge","Avoid superseding an issue onto one it already (transitively) depends on","Keep the database unlocked — don't run concurrent writers against the same DB"],"tags":["cli","dependency","storage"],"backgroundTag":"dependency-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}