{"record":{"id":"50461479defa226c","repo":"gastownhall/beads","slug":"issue-not-found-s-504614","errorCode":null,"errorMessage":"issue not found: %s","messagePattern":"issue not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/bulk_ops.go","lineNumber":304,"sourceCode":"\t\tif err := RecordDepEventInTx(ctx, tx, EventDepAdd, source, edge.kind, target, edge.metadata, actor); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc updateIssueIDInTx(ctx context.Context, tx *sql.Tx, oldID, newID string, issue *types.Issue, actor string) error {\n\tnow := time.Now().UTC()\n\tresult, err := tx.ExecContext(ctx, `\n\t\tUPDATE issues\n\t\tSET id = ?, title = ?, description = ?, design = ?, acceptance_criteria = ?, notes = ?, updated_at = ?\n\t\tWHERE id = ?\n\t`, newID, issue.Title, issue.Description, issue.Design, issue.AcceptanceCriteria, issue.Notes, now, oldID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"update issue ID: %w\", err)\n\t}\n\tif rows, _ := result.RowsAffected(); rows == 0 {\n\t\treturn fmt.Errorf(\"issue not found: %s\", oldID)\n\t}\n\n\tif err := UpdateIssueIDInDependenciesInTx(ctx, tx, oldID, newID); err != nil {\n\t\treturn err\n\t}\n\n\t// A live lease follows its issue across the rename.\n\tif _, err := tx.ExecContext(ctx,\n\t\t`UPDATE leases SET issue_id = ? WHERE issue_id = ?`, newID, oldID); err != nil {\n\t\treturn fmt.Errorf(\"rename lease row: %w\", err)\n\t}\n\n\treturn InsertDerivedEvent(ctx, tx, \"events\", AuxEvent{\n\t\tIssueID:   newID,\n\t\tEventType: \"renamed\",\n\t\tActor:     actor,\n\t\tOldValue:  str(oldID),\n\t\tNewValue:  str(newID),","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/bulk_ops.go#L286-L322","documentation":"The rename UPDATE executed successfully but affected zero rows, meaning no issue with oldID existed. The library reports this as a plain error (\"issue not found: %s\") so callers can distinguish a missing source issue from a driver failure. The transaction aborts with no changes.","triggerScenarios":"Calling UpdateIssueIDInTx/UpdateIssueID with an oldID that is not present in the issues table — already deleted, wrong prefix/format, or the issue is actually a wisp (lives in the wisps table, not issues).","commonSituations":"Stale client cache referencing an issue deleted by another process; ID case-sensitivity or typo (bd-12 vs bd-21); calling rename on a wisp ID instead of a real issue; multi-machine sync where the issue hasn't been pulled yet.","solutions":["Fetch the issue by oldID first and handle the not-found case before renaming.","Confirm the correct ID (check for typos, case, prefix) via `bd show <id>` or an equivalent query.","If the target is a wisp, use the wisp path (the library routes automatically only when the row exists).","Sync/pull latest data so the issue exists locally, then retry."],"exampleFix":"// before\nstore.UpdateIssueID(ctx, oldID, newID, issue, actor) // panics with 'issue not found' if stale\n// after\nif _, err := store.GetIssue(ctx, oldID); err != nil {\n    return fmt.Errorf(\"skip rename, source missing: %w\", err)\n}\nstore.UpdateIssueID(ctx, oldID, newID, issue, actor)","handlingStrategy":"validation","validationCode":"func mustExist(ctx context.Context, store Store, id string) error {\n    iss, err := store.GetIssue(ctx, id)\n    if err != nil { return err }\n    if iss == nil { return fmt.Errorf(\"issue %s not found; fetch latest before renaming\", id) }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"err := store.UpdateIssueID(ctx, oldID, newID, issue, actor)\nif err != nil && strings.HasPrefix(err.Error(), \"issue not found:\") {\n    // stale reference: re-sync and re-check\n    return handleStaleID(err, oldID)\n}","preventionTips":["Fetch the issue immediately before renaming instead of using cached IDs.","Sync latest state before bulk ID operations.","Distinguish wisp IDs from issue IDs in your tooling (different tables)."],"tags":["database","not-found","rename"],"backgroundTag":"issue-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}