usememos/memos · error

logical OR expects two arguments

Error message

logical OR expects two arguments

What it means

Returned by buildCallCondition for the "_||_" (logical OR) function when the call's argument count is not exactly 2. Like the AND twin, user-written CEL always yields binary ||, so this fires only from unusual AST shapes or macro desugaring.

Source

Thrown at internal/filter/parser.go:69

		if len(call.Args) != 2 {
			return nil, errors.New("logical AND expects two arguments")
		}
		left, err := buildCondition(call.Args[0], pc)
		if err != nil {
			return nil, err
		}
		right, err := buildCondition(call.Args[1], pc)
		if err != nil {
			return nil, err
		}
		return &LogicalCondition{
			Operator: LogicalAnd,
			Left:     left,
			Right:    right,
		}, nil
	case "_||_":
		if len(call.Args) != 2 {
			return nil, errors.New("logical OR expects two arguments")
		}
		left, err := buildCondition(call.Args[0], pc)
		if err != nil {
			return nil, err
		}
		right, err := buildCondition(call.Args[1], pc)
		if err != nil {
			return nil, err
		}
		return &LogicalCondition{
			Operator: LogicalOr,
			Left:     left,
			Right:    right,
		}, nil
	case "!_":
		if len(call.Args) != 1 {
			return nil, errors.New("logical NOT expects one argument")
		}

View on GitHub (pinned to 14d757ce1f)

Solutions

  1. Rewrite the || chain in explicit binary form with parentheses.
  2. When constructing ASTs directly, emit _||_ calls with exactly two arguments.
  3. Report as an engine bug if triggered by a plain filter.

Example fix

# before
(a || b || c)

# after
((a || b) || c)
Defensive patterns

Strategy: validation

Validate before calling

// Go — emit binary OR chains when generating
func orPair(l, r string) string { return fmt.Sprintf("(%s || %s)", l, r) }

Try / catch

if err != nil && strings.Contains(err.Error(), "logical OR expects two arguments") {
  return errors.Wrap(err, "internal filter AST inconsistency; report with the filter text")
}

Prevention

When it happens

Trigger: An Expr_Call tagged _||_ with arity != 2 in the parsed expression — e.g., from programmatic AST construction or a CEL macro that expands to OR over multiple args.

Common situations: Programmatic filter generation; edge-case macro expansions; effectively never from normal hand-written filters.

Related errors


AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15). Data as JSON: /api/errors/dda3cdb1fa4d5991. Report an issue: GitHub.