{"record":{"id":"1962535a4caa41aa","repo":"gastownhall/beads","slug":"count-wisp-events-w","errorCode":null,"errorMessage":"count wisp events: %w","messagePattern":"count wisp events: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/delete.go","lineNumber":235,"sourceCode":"\t\treturn nil, fmt.Errorf(\"count wisp dependencies: %w\", err)\n\t}\n\tdepsCount += wispDepsCount\n\n\tif labelsCount, err = CountRowsForIssueIDsInTx(ctx, tx, \"labels\", set.RegularIDs); err != nil {\n\t\treturn nil, fmt.Errorf(\"count labels: %w\", err)\n\t}\n\twispLabelsCount, err := CountRowsForIssueIDsInTx(ctx, tx, \"wisp_labels\", set.WispIDs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"count wisp labels: %w\", err)\n\t}\n\tlabelsCount += wispLabelsCount\n\n\tif eventsCount, err = CountRowsForIssueIDsInTx(ctx, tx, \"events\", set.RegularIDs); err != nil {\n\t\treturn nil, fmt.Errorf(\"count events: %w\", err)\n\t}\n\twispEventsCount, err := CountRowsForIssueIDsInTx(ctx, tx, \"wisp_events\", set.WispIDs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"count wisp events: %w\", err)\n\t}\n\teventsCount += wispEventsCount\n\n\tfor i := 0; i < len(set.All); i += deleteBatchSize {\n\t\tend := i + deleteBatchSize\n\t\tif end > len(set.All) {\n\t\t\tend = len(set.All)\n\t\t}\n\t\tbatch := set.All[i:end]\n\t\tbatchInClause, batchArgs := buildSQLInClause(batch)\n\n\t\tfor _, depTable := range []string{\"dependencies\", \"wisp_dependencies\"} {\n\t\t\trows, err := tx.QueryContext(ctx,\n\t\t\t\tfmt.Sprintf(`SELECT issue_id FROM %s WHERE %s`, depTable, depTargetIn(\"\", batchInClause)),\n\t\t\t\tbatchArgs...)\n\t\t\tif err != nil {\n\t\t\t\tif optionalBlockedTable(depTable) && isTableNotExistError(err) {\n\t\t\t\t\tcontinue","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/delete.go#L217-L253","documentation":"DeleteResolvedSetInTx aborts when it cannot count rows in the \"wisp_events\" table for the wisp IDs being deleted. This wraps the driver error from CountRowsForIssueIDsInTx and completes the events count for the dry-run delete result.","triggerScenarios":"Calling DeleteIssuesInTx/DeleteInTx when wisp_events does not exist (older schema, unsupported embedded driver) or the connection/transaction fails at this point in the count sequence.","commonSituations":"Version mismatch between beads binary and on-disk schema (wisp_events not yet migrated); Dolt server restart mid-delete; disk I/O errors on embedded databases.","solutions":["Inspect the wrapped error to identify missing-table vs connection causes.","Apply schema migrations so wisp_events exists.","Retry with a fresh transaction if the cause was transient.","Confirm backend/driver support for wisp tables (see the storage boundary docs)."],"exampleFix":"// before\nres, err := store.DeleteIssuesInTx(ctx, tx, ids)\n// after\nif err := migrator.EnsureSchema(ctx); err != nil {\n    return fmt.Errorf(\"schema out of date: %w\", err)\n}\nres, err := store.DeleteIssuesInTx(ctx, tx, ids)","handlingStrategy":"validation","validationCode":"var name string\nerr := db.QueryRowContext(ctx,\n    `SELECT table_name FROM information_schema.tables WHERE table_name = 'wisp_events'`).Scan(&name)\nif err != nil {\n    return errors.New(\"wisp_events missing: run schema migration before deleting wisps\")\n}","typeGuard":null,"tryCatchPattern":"res, err := store.DeleteInTx(ctx, tx, ids)\nif err != nil && strings.Contains(err.Error(), \"wisp_events\") {\n    return fmt.Errorf(\"schema missing wisp_events; run migration: %w\", err)\n}","preventionTips":["Align on-disk schema version with the beads binary version.","Include wisp-table presence in pre-flight health checks.","Back up the database before bulk deletes so corruption is recoverable."],"tags":["go","storage","transaction","sql","wisps"],"backgroundTag":"sql-count-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}