{"record":{"id":"7bcfb7cfbe194c98","repo":"gastownhall/beads","slug":"priority-d-matches-nothing","errorCode":null,"errorMessage":"priority < %d matches nothing","messagePattern":"priority < (.+?) matches nothing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/query/evaluator.go","lineNumber":244,"sourceCode":"\tpriority, err := strconv.Atoi(comp.Value)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid priority value: %s\", comp.Value)\n\t}\n\tif priority < 0 || priority > 4 {\n\t\treturn fmt.Errorf(\"priority must be between 0 and 4\")\n\t}\n\n\tswitch comp.Op {\n\tcase OpEquals:\n\t\tfilter.Priority = &priority\n\tcase OpNotEquals:\n\t\t// For != we need predicate filtering\n\t\treturn fmt.Errorf(\"priority != requires predicate filtering\")\n\tcase OpLess:\n\t\t// priority < X means PriorityMax = X-1\n\t\tmax := priority - 1\n\t\tif max < 0 {\n\t\t\treturn fmt.Errorf(\"priority < %d matches nothing\", priority)\n\t\t}\n\t\tfilter.PriorityMax = &max\n\tcase OpLessEq:\n\t\tfilter.PriorityMax = &priority\n\tcase OpGreater:\n\t\t// priority > X means PriorityMin = X+1\n\t\tmin := priority + 1\n\t\tif min > 4 {\n\t\t\treturn fmt.Errorf(\"priority > %d matches nothing\", priority)\n\t\t}\n\t\tfilter.PriorityMin = &min\n\tcase OpGreaterEq:\n\t\tfilter.PriorityMin = &priority\n\t}\n\treturn nil\n}\n\nfunc (e *Evaluator) applyTypeFilter(comp *ComparisonNode, filter *types.IssueFilter) error {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/query/evaluator.go#L226-L262","documentation":"The evaluator translates `priority < X` into PriorityMax = X-1. If X is 0, that bound would be -1, which no issue can have — so the evaluator short-circuits and reports that the comparison can never match anything instead of silently returning an empty result set. It's a contract check against a provably-empty query.","triggerScenarios":"Exactly `priority < 0` (or equivalent computed expressions resolving to 0): max := priority-1 = -1 < 0 triggers the error.","commonSituations":"Programmatic query builders computing `priority < minPriority` where minPriority is 0; user mistakes thinking priorities start at 1 when they start at 0.","solutions":["Remove the clause — no issue can have priority < 0; an empty result is guaranteed.","If \"lowest priority\" is intended, use `priority = 4` (or >= 3, etc.) explicitly.","Add a caller-side guard: skip emitting a `<` clause when the operand is <= 0."],"exampleFix":"// before (guaranteed empty)\n\"priority < 0\"\n// after — drop the clause, or express the intent\n\"priority = 4\"","handlingStrategy":"validation","validationCode":"func emitLessThanPriority(x int) (string, bool) {\n    if x-1 < 0 { return \"\", false } // priority < 0 matches nothing\n    return fmt.Sprintf(\"priority < %d\", x), true\n}","typeGuard":null,"tryCatchPattern":"if err := e.applyComparison(comp, filter); err != nil {\n    if strings.Contains(err.Error(), \"matches nothing\") {\n        return nil, nil // empty result is the correct, expected outcome\n    }\n    return err\n}","preventionTips":["Remember the priority scale starts at 0, so < 0 is always empty.","Guard generated clauses: skip < comparisons whose operand is <= 0.","Treat this error as informational — it flags a query that would return zero rows anyway."],"tags":["query","priority","logic","beads"],"backgroundTag":"impossible-query-condition","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}