gastownhall/beads · warning

priority < %d matches nothing

Error message

priority < %d matches nothing

What it means

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.

Source

Thrown at internal/query/evaluator.go:244

	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
	case OpLessEq:
		filter.PriorityMax = &priority
	case OpGreater:
		// priority > X means PriorityMin = X+1
		min := priority + 1
		if min > 4 {
			return fmt.Errorf("priority > %d matches nothing", priority)
		}
		filter.PriorityMin = &min
	case OpGreaterEq:
		filter.PriorityMin = &priority
	}
	return nil
}

func (e *Evaluator) applyTypeFilter(comp *ComparisonNode, filter *types.IssueFilter) error {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Remove the clause — no issue can have priority < 0; an empty result is guaranteed.
  2. If "lowest priority" is intended, use `priority = 4` (or >= 3, etc.) explicitly.
  3. Add a caller-side guard: skip emitting a `<` clause when the operand is <= 0.

Example fix

// before (guaranteed empty)
"priority < 0"
// after — drop the clause, or express the intent
"priority = 4"
Defensive patterns

Strategy: validation

Validate before calling

func emitLessThanPriority(x int) (string, bool) {
    if x-1 < 0 { return "", false } // priority < 0 matches nothing
    return fmt.Sprintf("priority < %d", x), true
}

Try / catch

if err := e.applyComparison(comp, filter); err != nil {
    if strings.Contains(err.Error(), "matches nothing") {
        return nil, nil // empty result is the correct, expected outcome
    }
    return err
}

Prevention

When it happens

Trigger: Exactly `priority < 0` (or equivalent computed expressions resolving to 0): max := priority-1 = -1 < 0 triggers the error.

Common situations: Programmatic query builders computing `priority < minPriority` where minPriority is 0; user mistakes thinking priorities start at 1 when they start at 0.

Related errors


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