usememos/memos · error
startsWith expects exactly one argument
Error message
startsWith expects exactly one argument
What it means
buildStartsWithPredicate translates t.startsWith("prefix"). It validates that the call target is the iteration variable and that exactly one argument is passed. More or fewer than one argument is rejected.
Source
Thrown at internal/filter/parser.go:960
}
return &EqualsPredicate{Value: valueStr}, nil
}
func isIterVarExpr(expr *exprv1.Expr, iterVar string) bool {
target := expr.GetIdentExpr()
return target != nil && target.GetName() == iterVar
}
// buildStartsWithPredicate extracts the pattern from t.startsWith("prefix").
func buildStartsWithPredicate(call *exprv1.Expr_Call, iterVar string) (PredicateExpr, error) {
// Verify the target is the iteration variable
if target := call.Target.GetIdentExpr(); target == nil || target.GetName() != iterVar {
return nil, errors.Errorf("startsWith target must be the iteration variable %q", iterVar)
}
if len(call.Args) != 1 {
return nil, errors.New("startsWith expects exactly one argument")
}
prefix, err := getConstValue(call.Args[0])
if err != nil {
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 {View on GitHub (pinned to 14d757ce1f)
Solutions
- Use the textual form tag.exists(t, t.startsWith("work"))
- Emit exactly one constant string argument when building the call AST
Defensive patterns
Strategy: try-catch
Try / catch
if err := r.Render(cond); err != nil {
if strings.Contains(err.Error(), "startsWith expects exactly one argument") {
return errors.New("call startsWith with a single quoted prefix")
}
return err
} Prevention
- Pass exactly one string argument to startsWith
- Use textual method-call syntax t.startsWith("...")
When it happens
Trigger: Programmatically constructed startsWith call with wrong arity; textual CEL always emits one arg, so this is a guard against malformed ASTs.
Common situations: AST-building tests or custom CEL environments emitting startsWith with 0 or 2 args.
Related errors
- endsWith 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/26dbd23de5bc1cc4.
Report an issue: GitHub.