{"record":{"id":"2b0af6b82e561eea","repo":"gastownhall/beads","slug":"delete-list-wisp-dependents-w","errorCode":null,"errorMessage":"delete: list wisp dependents: %w","messagePattern":"delete: list wisp dependents: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/issue_delete.go","lineNumber":236,"sourceCode":"\treturn result, nil\n}\n\n// externalDependents finds the direct dependents of each id in ids that are\n// not themselves in ids, across both the issue and wisp dependency tables.\n// The result maps deletion-set id -> external dependent ids (unsorted).\nfunc (u *issueUseCaseImpl) externalDependents(ctx context.Context, ids []string) (map[string][]string, error) {\n\tidSet := make(map[string]bool, len(ids))\n\tfor _, id := range ids {\n\t\tidSet[id] = true\n\t}\n\n\tissueRes, err := u.depRepo.ListByIssueIDs(ctx, ids, DepListOpts{Direction: DepDirectionIn})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"delete: list dependents: %w\", err)\n\t}\n\twispRes, err := u.depRepo.ListByIssueIDs(ctx, ids, DepListOpts{Direction: DepDirectionIn, UseWispsTable: true})\n\tif err != nil && !dberrors.IsTableNotExist(err) {\n\t\treturn nil, fmt.Errorf(\"delete: list wisp dependents: %w\", err)\n\t}\n\n\tout := map[string][]string{}\n\tseen := map[string]map[string]bool{}\n\tfor _, res := range []DepBulkResult{issueRes, wispRes} {\n\t\tfor target, deps := range res.Incoming {\n\t\t\tfor _, d := range deps {\n\t\t\t\tif d.IssueID == \"\" || idSet[d.IssueID] {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif seen[target] == nil {\n\t\t\t\t\tseen[target] = map[string]bool{}\n\t\t\t\t}\n\t\t\t\tif seen[target][d.IssueID] {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tseen[target][d.IssueID] = true\n\t\t\t\tout[target] = append(out[target], d.IssueID)","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/issue_delete.go#L218-L254","documentation":"This error wraps a failure from depRepo.ListByIssueIDs with UseWispsTable=true and Direction=DepDirectionIn in externalDependents. Unlike the issue-table query, a table-not-exist error is tolerated (wisps may never have been created in this DB); any other failure aborts the delete/preview flow.","triggerScenarios":"deleteMany -> externalDependents when the wisps dependency table exists but the incoming-dependency query against it fails for reasons other than table-not-exist: connection error, timeout, scan failure.","commonSituations":"Wisps table present but locked or corrupted; connection dropped mid-query; driver version mismatch after a beads upgrade altering the wisps schema.","solutions":["Inspect the wrapped error and exclude dberrors.IsTableNotExist cases (those are expected and ignored by design).","Fix the underlying connection/timeout issue and retry the delete.","Run a DB consistency/migration check if the wisps table exists but queries fail on schema.","If wisps are unused in your deployment, confirm the table truly doesn't exist — that path is silently skipped."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Only surface unexpected errors; missing wisps table is tolerated upstream:\n// ensure your DB either has the wisps tables migrated or none at all.\nif err := migrate(ctx); err != nil {\n    return fmt.Errorf(\"schema check failed: %w\", err)\n}","typeGuard":"var dbErr *dberrors.DBError\nif errors.As(err, &dbErr) && !dberrors.IsTableNotExist(err) {\n    // real failure, not the tolerated missing-wisps-table case\n}","tryCatchPattern":"_, err := uc.DeleteWisps(ctx, ids, opts)\nif err != nil && strings.Contains(err.Error(), \"delete: list wisp dependents\") {\n    if dberrors.IsTableNotExist(errors.Unwrap(err)) {\n        return nil // tolerated by design\n    }\n    return err\n}","preventionTips":["Run beads migrations so wisps tables match the binary version","Distinguish IsTableNotExist (tolerated) from other driver errors","Avoid concurrent wisp writes during delete operations","Retry transient connection failures"],"tags":["go","storage","wisps","dependencies"],"backgroundTag":"dependency-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}