{"record":{"id":"dc523394e8e09deb","repo":"gastownhall/beads","slug":"iter-issues-build-filter-w","errorCode":null,"errorMessage":"iter issues: build filter: %w","messagePattern":"iter issues: build filter: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/iter_issues.go","lineNumber":45,"sourceCode":"\t\"github.com/steveyegge/beads/internal/storage\"\n\t\"github.com/steveyegge/beads/internal/storage/issueops\"\n\t\"github.com/steveyegge/beads/internal/storage/sqlbuild\"\n\t\"github.com/steveyegge/beads/internal/types\"\n)\n\n// IterIssues returns issues matching the filter from the `issues` table.\n//\n// The path queries only the issues table (wisps are returned separately via\n// IterWisps). The slice path SearchIssues merges both for backward\n// compatibility — that merge needs a seen-set keyed by ID across the full\n// issues result set, so it stays separate from this issues-only iterator.\nfunc (s *DoltStore) IterIssues(ctx context.Context, query string, filter types.IssueFilter) (storage.Iter[types.Issue], error) {\n\tif s.closed.Load() {\n\t\treturn nil, ErrStoreClosed\n\t}\n\twhereClauses, args, err := issueops.BuildIssueFilterClauses(query, filter, issueops.IssuesFilterTables)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"iter issues: build filter: %w\", err)\n\t}\n\twhereSQL := \"\"\n\tif len(whereClauses) > 0 {\n\t\twhereSQL = \"WHERE \" + strings.Join(whereClauses, \" AND \")\n\t}\n\tlimitSQL := \"\"\n\tif filter.Limit > 0 {\n\t\tlimitSQL = fmt.Sprintf(\" LIMIT %d\", filter.Limit)\n\t}\n\n\t//nolint:gosec // G201: whereSQL contains column comparisons with ?, limitSQL is a safe integer\n\tq := fmt.Sprintf(`SELECT %s FROM issues %s %s ORDER BY priority ASC, created_at DESC, id ASC%s`,\n\t\tissueops.IssueSelectColumns, sqlbuild.LeaseJoin(\"issues\"), whereSQL, limitSQL)\n\n\tvar issues []*types.Issue\n\ttxErr := s.withReadTx(ctx, func(tx *sql.Tx) error {\n\t\trows, err := tx.QueryContext(ctx, q, args...)\n\t\tif err != nil {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/iter_issues.go#L27-L63","documentation":"IterIssues failed while translating the caller's query string and IssueFilter into SQL WHERE clauses via issueops.BuildIssueFilterClauses. The filter could not be compiled to valid SQL, so no query is issued. This is a caller-input problem, not a storage problem.","triggerScenarios":"Calling DoltStore.IterIssues(ctx, query, filter) with a filter containing an unsupported field/operator, a malformed query expression, or a value that fails type conversion inside BuildIssueFilterClauses.","commonSituations":"Passing free-text query syntax the filter builder doesn't understand; using a filter field added in a newer beads version with an older storage layer; programmatically constructed filters with invalid values (empty operator, bad date format).","solutions":["Inspect the wrapped error to identify the offending filter field or query clause","Simplify the IssueFilter to a minimal known-good case (e.g. status only) and add fields back one at a time","Validate query/filter syntax against the supported filter grammar for your beads version","Upgrade beads if the filter uses features newer than your binary"],"exampleFix":"// before: unsupported operator\nfilter := types.IssueFilter{Assignee: &f, Labels: []string{\"x\"}, Status: \"in:open,closed\"}\n\n// after: use supported fields/operators\nfilter := types.IssueFilter{Assignee: &f, Status: \"open\"}","handlingStrategy":"validation","validationCode":"// Validate filter fields before calling IterIssues\nif filter.Status != \"\" && !isValidStatus(filter.Status) {\n    return fmt.Errorf(\"unsupported status filter: %q\", filter.Status)\n}","typeGuard":null,"tryCatchPattern":"iter, err := store.IterIssues(ctx, query, filter)\nif err != nil {\n    if strings.Contains(err.Error(), \"build filter\") {\n        // caller-input problem: fix filter/query, not storage\n        return fmt.Errorf(\"invalid issue filter: %w\", err)\n    }\n    return err\n}","preventionTips":["Build filters only from documented IssueFilter fields and operators","Unit-test filter construction against the supported grammar","Pin beads versions when using programmatic filters"],"tags":["storage","dolt","filter","input-validation"],"backgroundTag":"invalid-query-filter","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}