{"record":{"id":"9d8cee4d5ff430b2","repo":"gastownhall/beads","slug":"failed-to-close-superseded-issue-w","errorCode":null,"errorMessage":"failed to close superseded issue: %w","messagePattern":"failed to close superseded issue: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/duplicate.go","lineNumber":183,"sourceCode":"\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\n\tfmt.Printf(\"%s Marked %s as superseded by %s (closed)\\n\", ui.RenderPass(\"✓\"), oldID, newID)\n\treturn nil\n}\n","sourceCodeStart":165,"sourceCodeEnd":199,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/duplicate.go#L165-L199","documentation":"After the supersede edge is written, runSupersede closes the old issue through store.CloseIssue so the closure records the full lifecycle state. A failure here is wrapped with this message. The supersede dependency may already be persisted, so the state is partially applied: edge exists, old issue still open.","triggerScenarios":"CloseIssue on the old issue fails: store write error, the old issue was concurrently deleted or already closed by another actor, or the underlying Dolt transaction aborted.","commonSituations":"Two agents/users superseding the same issue concurrently; an automated job closed the old issue between the dependency write and the close; DB connectivity dropped mid-command.","solutions":["Check the old issue state: if it is now closed and the supersedes edge exists, the supersede effectively completed — nothing to redo","If the old issue is still open, re-run `bd supersede`; the dependency step tolerates re-application","Inspect the wrapped cause with `bd doctor` for DB-level problems","Use `bd update <oldID> --status closed` as a manual fallback if the lifecycle op keeps failing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if st, err := getIssueStatus(oldID); err == nil && st == \"closed\" { /* already superseded/closed; skip */ }","typeGuard":null,"tryCatchPattern":"if err := runSupersede(ctx, oldID, newID, actor); err != nil {\n    if strings.Contains(err.Error(), \"failed to close superseded issue\") {\n        // idempotent recovery: check status; close manually if still open\n        _ = runBd(\"update\", oldID, \"--status\", \"closed\")\n    }\n}","preventionTips":["Treat supersede as partially-resumable: verify old issue status after a failure","Avoid concurrent supersede/close of the same issue from multiple agents","Retry promptly while the DB connection is still healthy"],"tags":["cli","issue-lifecycle","close"],"backgroundTag":"issue-close-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}