usememos/memos · error
contains expects exactly one argument
Error message
contains expects exactly one argument
What it means
buildContainsPredicate translates t.contains("substring") and requires exactly one argument after validating the target is the iteration variable. Any other arity is rejected.
Source
Thrown at internal/filter/parser.go:1006
return nil, errors.Wrap(err, "endsWith argument must be a constant string")
}
suffixStr, ok := suffix.(string)
if !ok {
return nil, errors.New("endsWith argument must be a string")
}
return &EndsWithPredicate{Suffix: suffixStr}, nil
}
// buildContainsPredicate extracts the pattern from t.contains("substring").
func buildContainsPredicate(call *exprv1.Expr_Call, iterVar string) (PredicateExpr, error) {
if target := call.Target.GetIdentExpr(); target == nil || target.GetName() != iterVar {
return nil, errors.Errorf("contains target must be the iteration variable %q", iterVar)
}
if len(call.Args) != 1 {
return nil, errors.New("contains expects exactly one argument")
}
substring, err := getConstValue(call.Args[0])
if err != nil {
return nil, errors.Wrap(err, "contains argument must be a constant string")
}
substringStr, ok := substring.(string)
if !ok {
return nil, errors.New("contains argument must be a string")
}
return &ContainsPredicate{Substring: substringStr}, nil
}
View on GitHub (pinned to 14d757ce1f)
Solutions
- Use the textual form tag.exists(t, t.contains("work"))
- Emit exactly one argument when building the contains call node
Defensive patterns
Strategy: try-catch
Try / catch
if err := r.Render(cond); err != nil {
if strings.Contains(err.Error(), "contains expects exactly one argument") {
return errors.New("call contains with a single quoted substring")
}
return err
} Prevention
- Pass exactly one string argument to contains
- Use textual method syntax t.contains("...")
When it happens
Trigger: Programmatically constructed contains call with wrong argument count; textual CEL always emits one argument, so this guard fires only on malformed ASTs.
Common situations: AST construction in tests; custom macro expansion emitting multi-arg contains.
Related errors
- startsWith expects exactly one argument
- endsWith expects exactly one argument
- comprehension accumulator must be initialized with a constan
- unsupported comprehension type (supported: exists, all, exis
- comprehension loop step must be a call expression
AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15).
Data as JSON: /api/errors/d65070e949d06968.
Report an issue: GitHub.