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
- Rewrite the || chain in explicit binary form with parentheses.
- When constructing ASTs directly, emit _||_ calls with exactly two arguments.
- 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
- Parenthesize every generated || chain.
- Test generated filters against the real engine before shipping.
- Treat arity errors from hand-written filters as bugs, not user errors.
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
- filter must evaluate to a boolean value
- unsupported top-level expression
- logical AND expects two arguments
- logical NOT expects one argument
- comparison expects two arguments
AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15).
Data as JSON: /api/errors/dda3cdb1fa4d5991.
Report an issue: GitHub.