{"record":{"id":"4d6a6989feb3a34e","repo":"usememos/memos","slug":"size-expects-one-argument-4d6a69","errorCode":null,"errorMessage":"size() expects one argument","messagePattern":"size\\(\\) expects one argument","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/filter/render.go","lineNumber":262,"sourceCode":"\t\toff = spec.off[1]\n\tcase DialectMySQL:\n\t\tbase = fmt.Sprintf(\"%s(%s)\", spec.mysql, col)\n\t\toff = spec.off[2]\n\tdefault:\n\t\treturn \"\", errors.Errorf(\"unsupported dialect %q\", r.dialect)\n\t}\n\tif off != 0 {\n\t\tbase = fmt.Sprintf(\"(%s - %d)\", base, off)\n\t}\n\treturn base, nil\n}\n\nfunc (r *renderer) renderFunctionComparison(fn *FunctionValue, op ComparisonOperator, right ValueExpr) (renderResult, error) {\n\tif fn.Name != \"size\" {\n\t\treturn renderResult{}, errors.Errorf(\"unsupported function %s in comparison\", fn.Name)\n\t}\n\tif len(fn.Args) != 1 {\n\t\treturn renderResult{}, errors.New(\"size() expects one argument\")\n\t}\n\tfieldArg, ok := fn.Args[0].(*FieldRef)\n\tif !ok {\n\t\treturn renderResult{}, errors.New(\"size() argument must be a field\")\n\t}\n\n\tfield, ok := r.schema.Field(fieldArg.Name)\n\tif !ok {\n\t\treturn renderResult{}, errors.Errorf(\"unknown field %q\", fieldArg.Name)\n\t}\n\tif field.Kind == FieldKindVirtualAlias {\n\t\tfield, ok = r.schema.ResolveAlias(fieldArg.Name)\n\t\tif !ok {\n\t\t\treturn renderResult{}, errors.Errorf(\"invalid alias %q\", fieldArg.Name)\n\t\t}\n\t}\n\n\tvalue, err := expectNumericLiteral(right)","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/usememos/memos/blob/14d757ce1fb31c78590f374bc042f8dbedbc20d7/internal/filter/render.go#L244-L280","documentation":"renderFunctionComparison supports only size(), and requires it to have exactly one argument. A FunctionValue named size with zero or multiple args cannot name a field to measure and fails here.","triggerScenarios":"Programmatically built FunctionValue{Name:\"size\", Args: []} or Args with 2+ entries; textual CEL's size(x) macro always emits one arg, so this fires on malformed ASTs or direct condition construction.","commonSituations":"Custom ValueExpr/FunctionValue construction in code that reuses the renderer; tests building conditions by hand.","solutions":["Use the textual form size(field) or field.size(), e.g. content.size() > 100","When constructing FunctionValue programmatically, pass exactly one FieldRef argument"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if fn.Name == \"size\" && len(fn.Args) != 1 {\n    return errors.New(\"size() takes exactly one field argument\")\n}","typeGuard":"func isValidSizeCall(fn *filter.FunctionValue) bool {\n    return fn.Name == \"size\" && len(fn.Args) == 1\n}","tryCatchPattern":"if err := validateFn(fn); err != nil {\n    return fmt.Errorf(\"invalid size() usage: %w\", err)\n}","preventionTips":["Always write size(field) or field.size() with exactly one field argument","Validate FunctionValue arity before handing conditions to the renderer"],"tags":["cel","filter","renderer","sql","size-function"],"backgroundTag":null,"analyzedSha":"14d757ce1fb31c78590f374bc042f8dbedbc20d7","analyzedAt":"2026-08-15T09:27:36.538Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}