{"record":{"id":"857c9c00b835c207","repo":"gastownhall/beads","slug":"delete-drop-wisp-labels-w","errorCode":null,"errorMessage":"delete: drop wisp labels: %w","messagePattern":"delete: drop wisp labels: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/issue_delete.go","lineNumber":187,"sourceCode":"\tif _, err := u.depRepo.DeleteAllForIDs(ctx, wispIDs, DepInsertOpts{UseWispsTable: true}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop wisp deps: %w\", err)\n\t}\n\t// The SYNC-PLANE edges pointing at a deleted wisp, which are not the same\n\t// rows as the line above and are not reached by a foreign key: there is no\n\t// FK from dependencies to wisps, so `dependencies.depends_on_wisp_id` rows\n\t// survive their target unless they are deleted explicitly. Without this a\n\t// forced delete of a wisp left its durable dependent holding an edge into\n\t// a row that no longer exists — dangling, not orphaned, which is not what\n\t// issueops.DeleteRequest.Force promises. The store body has always done\n\t// this (issueops.deleteIssueRowInTx -> DeleteWispFromDependenciesInTx).\n\tif _, err := u.depRepo.DeleteAllForIDs(ctx, wispIDs, DepInsertOpts{}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop sync-plane edges into deleted wisps: %w\", err)\n\t}\n\tif _, err := u.labelRepo.DeleteAllForIDs(ctx, regularIDs, LabelOpts{}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop labels: %w\", err)\n\t}\n\tif _, err := u.labelRepo.DeleteAllForIDs(ctx, wispIDs, LabelOpts{UseWispsTable: true}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop wisp labels: %w\", err)\n\t}\n\tif _, err := u.eventsRepo.DeleteAllForIDs(ctx, regularIDs, RecordEventOpts{}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop events: %w\", err)\n\t}\n\tif _, err := u.eventsRepo.DeleteAllForIDs(ctx, wispIDs, RecordEventOpts{UseWispsTable: true}); err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop wisp events: %w\", err)\n\t}\n\n\tissuesDeleted, err := u.issueRepo.DeleteByIDs(ctx, regularIDs, IssueTableOpts{})\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop issue rows: %w\", err)\n\t}\n\twispsDeleted, err := u.issueRepo.DeleteByIDs(ctx, wispIDs, IssueTableOpts{UseWispsTable: true})\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"delete: drop wisp rows: %w\", err)\n\t}\n\tresult.DeletedCount = issuesDeleted + wispsDeleted\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/issue_delete.go#L169-L205","documentation":"Same label cascade step as 'drop labels' but for the wisp-plane: labelRepo.DeleteAllForIDs with UseWispsTable:true removes label rows stored against wisps. A wrapped error here means the wisp label rows could not be deleted and the entire delete aborts to avoid inconsistent state.","triggerScenarios":"Deleting wisps (DeleteWisp/DeleteWisps or mixed sets) when the wisps labels table is missing/locked, the driver errors, or the context/connection fails during the cascade.","commonSituations":"Older embedded DB without the wisps labels table; concurrent writer lock timeouts; transient connection drop during large wisp deletions.","solutions":["Verify the wisps labels table exists; migrate the embedded schema if needed.","Retry the delete — no partial rows persist on failure.","Check the wrapped cause for lock/permission specifics.","Chunk large wisp deletions to stay under lock timeouts."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if err := ctx.Err(); err != nil { return err }\nexists, err := tableExists(ctx, \"wisps_labels\"); if err != nil || !exists { return fmt.Errorf(\"wisp labels table missing — migrate schema\") }","typeGuard":"var dbe *storage.DBError\nif errors.As(err, &dbe) { /* inspect driver cause */ }","tryCatchPattern":"if err := store.DeleteWisps(ctx, ids, opts); err != nil {\n    if strings.Contains(err.Error(), \"delete: drop wisp labels:\") { /* retry after schema/health check */ }\n}","preventionTips":["Migrate databases predating wisp label tables.","Run bd doctor on embedded stores.","Limit deletion batch sizes.","Single-writer discipline for the database file."],"tags":["storage","database","wisps","labels"],"backgroundTag":"label-delete-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}