usememos/memos · error
endsWith expects exactly one argument
Error message
endsWith expects exactly one argument
What it means
buildEndsWithPredicate translates t.endsWith("suffix") and requires exactly one argument after confirming the target is the iteration variable. Wrong arity is rejected here.
Source
Thrown at internal/filter/parser.go:983
return nil, errors.Wrap(err, "startsWith argument must be a constant string")
}
prefixStr, ok := prefix.(string)
if !ok {
return nil, errors.New("startsWith argument must be a string")
}
return &StartsWithPredicate{Prefix: prefixStr}, nil
}
// buildEndsWithPredicate extracts the pattern from t.endsWith("suffix").
func buildEndsWithPredicate(call *exprv1.Expr_Call, iterVar string) (PredicateExpr, error) {
if target := call.Target.GetIdentExpr(); target == nil || target.GetName() != iterVar {
return nil, errors.Errorf("endsWith target must be the iteration variable %q", iterVar)
}
if len(call.Args) != 1 {
return nil, errors.New("endsWith expects exactly one argument")
}
suffix, err := getConstValue(call.Args[0])
if err != nil {
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 {View on GitHub (pinned to 14d757ce1f)
Solutions
- Use the textual form tag.exists(t, t.endsWith("work"))
- Emit exactly one argument for endsWith when constructing Expr_Call nodes
Defensive patterns
Strategy: try-catch
Try / catch
if err := r.Render(cond); err != nil {
if strings.Contains(err.Error(), "endsWith expects exactly one argument") {
return errors.New("call endsWith with a single quoted suffix")
}
return err
} Prevention
- Pass exactly one string argument to endsWith
- Use textual method syntax t.endsWith("...")
When it happens
Trigger: Programmatically built endsWith call with 0 or 2+ args; not reachable from textual CEL, which always passes one argument.
Common situations: Direct AST construction in tests or custom macro pipelines.
Related errors
- startsWith expects exactly one argument
- contains 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/69a790769d7776cc.
Report an issue: GitHub.