gastownhall/beads · error

invalid priority value: %s

Error message

invalid priority value: %s

What it means

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.

Source

Thrown at internal/query/evaluator.go:228

	if comp.Op != OpEquals && comp.Op != OpNotEquals {
		return fmt.Errorf("status only supports = and != operators")
	}
	status := types.Status(strings.ToLower(comp.Value))
	if !status.IsValid() {
		return fmt.Errorf("invalid status: %s", comp.Value)
	}
	if comp.Op == OpEquals {
		filter.Status = &status
	} else {
		filter.ExcludeStatus = append(filter.ExcludeStatus, status)
	}
	return nil
}

func (e *Evaluator) applyPriorityFilter(comp *ComparisonNode, filter *types.IssueFilter) error {
	priority, err := strconv.Atoi(comp.Value)
	if err != nil {
		return fmt.Errorf("invalid priority value: %s", comp.Value)
	}
	if priority < 0 || priority > 4 {
		return fmt.Errorf("priority must be between 0 and 4")
	}

	switch comp.Op {
	case OpEquals:
		filter.Priority = &priority
	case OpNotEquals:
		// For != we need predicate filtering
		return fmt.Errorf("priority != requires predicate filtering")
	case OpLess:
		// priority < X means PriorityMax = X-1
		max := priority - 1
		if max < 0 {
			return fmt.Errorf("priority < %d matches nothing", priority)
		}
		filter.PriorityMax = &max

View on GitHub (pinned to 71377f2769)

Solutions

  1. Use the bare integer 0–4: e.g. `priority = 1` instead of `priority = P1`.
  2. Strip a leading "P"/"p" and surrounding whitespace from user-supplied values before building the query.
  3. If a named mapping is needed, translate names to numbers first: high→1, medium→2, low→3, backlog→4 (critical/urgent→0).

Example fix

// before
"priority = P1"
// after
"priority = 1"
// name-to-number mapping in Go
n := strings.TrimPrefix(strings.ToLower(v), "p")
// then validate n is 0-4
Defensive patterns

Strategy: validation

Validate before calling

func normalizePriority(v string) (int, error) {
    n, err := strconv.Atoi(strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(v), "P")))
    if err != nil {
        return 0, fmt.Errorf("priority must be an integer 0-4, got %q", v)
    }
    return n, nil
}

Try / catch

if err := e.applyComparison(comp, filter); err != nil {
    if strings.HasPrefix(err.Error(), "invalid priority value:") {
        return fmt.Errorf("use a numeric priority 0-4 (e.g. priority = 1), not %q", comp.Value)
    }
    return err
}

Prevention

When it happens

Trigger: Queries like `priority = high`, `priority = "2 "` (trailing space), `priority = p1`, `priority = 2.0`, or an empty value `priority =`.

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/71d1853b6dd68a6c. Report an issue: GitHub.