usememos/memos · error
in operator expects two arguments
Error message
in operator expects two arguments
What it means
Returned by buildInCondition (internal/filter/parser.go) when an "@in" operator call does not have exactly 2 arguments (element, list). CEL's 'in' is always binary, so like the other arity guards this protects against malformed or programmatically built ASTs.
Source
Thrown at internal/filter/parser.go:264
func asFloats(left, right any) (float64, float64, bool) {
l, lok := toFloat(left)
r, rok := toFloat(right)
return l, r, lok && rok
}
func toFloat(v any) (float64, bool) {
switch x := v.(type) {
case int64:
return float64(x), true
case float64:
return x, true
}
return 0, false
}
func buildInCondition(call *exprv1.Expr_Call, pc parseContext) (Condition, error) {
if len(call.Args) != 2 {
return nil, errors.New("in operator expects two arguments")
}
// Handle identifier in list syntax.
if identName, err := getIdentName(call.Args[0]); err == nil {
if field, ok := pc.schema.Field(identName); ok && field.Kind == FieldKindVirtualAlias {
if _, aliasOk := pc.schema.ResolveAlias(identName); !aliasOk {
return nil, errors.Errorf("invalid alias %q", identName)
}
} else if !ok {
return nil, errors.Errorf("unknown identifier %q", identName)
}
if listExpr := call.Args[1].GetListExpr(); listExpr != nil {
values := make([]ValueExpr, 0, len(listExpr.Elements))
for _, element := range listExpr.Elements {
value, err := buildValueExpr(element, pc)
if err != nil {
return nil, errView on GitHub (pinned to 14d757ce1f)
Solutions
- Use the standard form: <value> in <list>.
- When emitting ASTs, construct @in calls with exactly two arguments.
- Report as an engine bug if a plain filter triggers it.
Example fix
# before (AST misuse) # after tag in ["work", "idea"]
Defensive patterns
Strategy: validation
Validate before calling
// Go — generate @in as exactly (element, list)
func inList(elem, list string) string { return fmt.Sprintf("%s in %s", elem, list) } Try / catch
if err != nil && strings.Contains(err.Error(), "in operator expects two arguments") {
return errors.Wrap(err, "internal filter AST inconsistency; report with the filter text")
} Prevention
- Use '<value> in <list>' text form; never build @in ASTs with extra args.
- Validate list literals are well-formed before embedding them.
- Round-trip generated in-filters through Compile in tests.
When it happens
Trigger: An Expr_Call for @in with arity != 2 — from custom AST construction or macro expansion, not from ordinary filters like tag in ["a","b"].
Common situations: Programmatic filter generation; synthetic parser tests.
Related errors
- invalid use of in operator
- filter must evaluate to a boolean value
- unsupported top-level expression
- logical AND expects two arguments
- logical OR expects two arguments
AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15).
Data as JSON: /api/errors/438f69af49f6e782.
Report an issue: GitHub.