{"record":{"id":"71d1853b6dd68a6c","repo":"gastownhall/beads","slug":"invalid-priority-value-s","errorCode":null,"errorMessage":"invalid priority value: %s","messagePattern":"invalid priority value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/query/evaluator.go","lineNumber":228,"sourceCode":"\tif comp.Op != OpEquals && comp.Op != OpNotEquals {\n\t\treturn fmt.Errorf(\"status only supports = and != operators\")\n\t}\n\tstatus := types.Status(strings.ToLower(comp.Value))\n\tif !status.IsValid() {\n\t\treturn fmt.Errorf(\"invalid status: %s\", comp.Value)\n\t}\n\tif comp.Op == OpEquals {\n\t\tfilter.Status = &status\n\t} else {\n\t\tfilter.ExcludeStatus = append(filter.ExcludeStatus, status)\n\t}\n\treturn nil\n}\n\nfunc (e *Evaluator) applyPriorityFilter(comp *ComparisonNode, filter *types.IssueFilter) error {\n\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","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/query/evaluator.go#L210-L246","documentation":"applyPriorityFilter parses the comparison value with strconv.Atoi before using it. If the value is not a valid plain integer (empty, non-numeric, or containing units/whitespace), the query is rejected with this error. Beads priorities are integers 0–4, so the parser is strict about the value format.","triggerScenarios":"Queries like `priority = high`, `priority = \"2 \"` (trailing space), `priority = p1`, `priority = 2.0`, or an empty value `priority =`.","commonSituations":"Users typing named priorities (P1, high, urgent) as they appear in CLI output instead of the numeric value; scripts interpolating formatted priority labels (\"P2\") into queries; locale-formatted numbers or decimals from generated queries.","solutions":["Use the bare integer 0–4: e.g. `priority = 1` instead of `priority = P1`.","Strip a leading \"P\"/\"p\" and surrounding whitespace from user-supplied values before building the query.","If a named mapping is needed, translate names to numbers first: high→1, medium→2, low→3, backlog→4 (critical/urgent→0)."],"exampleFix":"// before\n\"priority = P1\"\n// after\n\"priority = 1\"\n// name-to-number mapping in Go\nn := strings.TrimPrefix(strings.ToLower(v), \"p\")\n// then validate n is 0-4","handlingStrategy":"validation","validationCode":"func normalizePriority(v string) (int, error) {\n    n, err := strconv.Atoi(strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(v), \"P\")))\n    if err != nil {\n        return 0, fmt.Errorf(\"priority must be an integer 0-4, got %q\", v)\n    }\n    return n, nil\n}","typeGuard":null,"tryCatchPattern":"if err := e.applyComparison(comp, filter); err != nil {\n    if strings.HasPrefix(err.Error(), \"invalid priority value:\") {\n        return fmt.Errorf(\"use a numeric priority 0-4 (e.g. priority = 1), not %q\", comp.Value)\n    }\n    return err\n}","preventionTips":["Strip P-prefixes, units, and whitespace from priority inputs before building queries.","Map human names (high/medium/low) to 0-4 integers at the UI boundary.","Reject non-integer priority strings in form/script validation."],"tags":["query","priority","parsing","beads"],"backgroundTag":"invalid-numeric-input","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}