usememos/memos · error

size() expects one argument

Error message

size() expects one argument

What it means

The size() function inside a filter value expression (e.g. comparing tag list lengths) must take exactly one argument. buildValueExpr's switch on call.Function builds a FunctionValue{Name:"size"} with a single compiled argument; any other arity is rejected because there is no SQL translation for it.

Source

Thrown at internal/filter/parser.go:413

		return nil, err
	} else if ok {
		return &LiteralValue{Value: value}, nil
	}

	if boolVal, ok, err := evaluateBoolExpr(expr); err != nil {
		return nil, err
	} else if ok {
		return &LiteralValue{Value: boolVal}, nil
	}

	if call := expr.GetCallExpr(); call != nil {
		if call.Target != nil && isTimestampAccessor(call.Function) {
			return buildTimestampAccessor(call, pc)
		}
		switch call.Function {
		case "size":
			if len(call.Args) != 1 {
				return nil, errors.New("size() expects one argument")
			}
			arg, err := buildValueExpr(call.Args[0], pc)
			if err != nil {
				return nil, err
			}
			return &FunctionValue{
				Name: "size",
				Args: []ValueExpr{arg},
			}, nil
		case "_+_", "_-_", "_*_":
			value, ok, err := evaluateNumeric(expr, pc.now)
			if err != nil {
				return nil, err
			}
			if ok {
				return &LiteralValue{Value: value}, nil
			}
		default:

View on GitHub (pinned to 14d757ce1f)

Solutions

  1. Pass one list field: size(tag) == 0
  2. Combine multiple size comparisons with && instead of extra arguments
  3. Check the schema for which fields are JSON lists before using size()

Example fix

// before
size() == 0

// after
size(tag) == 0
Defensive patterns

Strategy: validation

Validate before calling

// TS: before submitting, assert every size( has exactly one field arg
const bad = [...filter.matchAll(/size\(([^)]*)\)/g)].some(m => m[1].split(',').length !== 1 || m[1].trim() === '');
if (bad) throw new Error('size() takes exactly one list field');

Prevention

When it happens

Trigger: Filters like size() == 0 or size(tag, visibility) > 1 — the parser sees len(call.Args) != 1 inside the value-expression path and errors out.

Common situations: Assuming size() with no args returns a default field's size; porting SQL-ish count(col1, col2) habits into the CEL filter.

Related errors


AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15). Data as JSON: /api/errors/20026d69a042e7ec. Report an issue: GitHub.