{"record":{"id":"54114c75ce82b68f","repo":"gastownhall/beads","slug":"search-issues-w-54114c","errorCode":null,"errorMessage":"search issues: %w","messagePattern":"search issues: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/issue_search.go","lineNumber":53,"sourceCode":"\tname, ok := dberrors.MissingTableName(err)\n\treturn ok && sqlbuild.OptionalWispTable(name)\n}\n\nfunc (r *issueSQLRepositoryImpl) searchAcrossIssuesAndWisps(ctx context.Context, query string, filter types.IssueFilter) (domain.SearchPage, error) {\n\tif filter.Ephemeral != nil && *filter.Ephemeral {\n\t\tpage, err := r.searchTable(ctx, query, filter, wispsFilterTables)\n\t\tif err != nil && !missingOptionalWispTable(err) {\n\t\t\treturn domain.SearchPage{}, fmt.Errorf(\"search wisps (ephemeral filter): %w\", err)\n\t\t}\n\t\tif len(page.Items) > 0 {\n\t\t\treturn page, nil\n\t\t}\n\t}\n\n\tif filter.SkipWisps {\n\t\tpage, err := r.searchTable(ctx, query, filter, issuesFilterTables)\n\t\tif err != nil {\n\t\t\treturn domain.SearchPage{}, fmt.Errorf(\"search issues: %w\", err)\n\t\t}\n\t\treturn page, nil\n\t}\n\n\tempty, probeErr := r.wispsTableEmptyOrMissing(ctx)\n\tif probeErr != nil {\n\t\treturn domain.SearchPage{}, fmt.Errorf(\"search wisps (merge): probe: %w\", probeErr)\n\t}\n\tif empty {\n\t\tpage, err := r.searchTable(ctx, query, filter, issuesFilterTables)\n\t\tif err != nil {\n\t\t\treturn domain.SearchPage{}, fmt.Errorf(\"search issues: %w\", err)\n\t\t}\n\t\treturn page, nil\n\t}\n\n\treturn r.searchUnion(ctx, query, filter)\n}","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/issue_search.go#L35-L71","documentation":"searchAcrossIssuesAndWisps wraps a failure from searchTable against the durable issues table when filter.SkipWisps is set. This is the issues-only search path: any SQL execution, scan, or hydration error from searching the issues table is wrapped as \"search issues\". The issues table is mandatory, so no table-not-exist tolerance applies.","triggerScenarios":"Calling SearchAcrossIssuesAndWisps with SkipWisps=true when the issues-table search fails: bad query/filter combination producing invalid SQL, missing labels/dependencies tables during hydration, connection drop, or ctx cancellation.","commonSituations":"Search strings or filter values that break clause building; databases missing the labels or dependencies table; Dolt server unreachable; oversized result sets hitting the MaxRows cap in combination with other errors.","solutions":["Read the wrapped inner error (search issues: <table>: ...) to find the failing statement","Simplify the query/filter to isolate which clause breaks; check for characters or fields the filter builder mishandles","Run bd doctor to verify mandatory tables (issues, labels, dependencies) exist","Retry on transient connection errors and check Dolt server health"],"exampleFix":"// before: opaque filter passed straight through\npage, err := store.Search(ctx, rawUserQuery, userFilter)\n// after: validate/limit the filter first\nif userFilter.MaxRows == 0 { userFilter.MaxRows = 1000 }\npage, err := store.Search(ctx, rawUserQuery, userFilter)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"page, err := store.Search(ctx, q, types.IssueFilter{SkipWisps: true})\nif err != nil && strings.Contains(err.Error(), \"search issues\") {\n    var tbl string\n    if name, ok := dberrors.MissingTableName(errors.Unwrap(err)); ok {\n        tbl = name\n        // missing mandatory table: repair via bd doctor / restore\n    }\n}","preventionTips":["Validate user-supplied query/filter input before passing to Search","Run bd doctor after any schema-affecting operation","Set sane MaxRows limits on user-triggered searches","Handle transient connection errors with bounded retries"],"tags":["database","search","issues","sql"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}