{"record":{"id":"3cb498400b6891fa","repo":"usememos/memos","slug":"logical-and-expects-two-arguments","errorCode":null,"errorMessage":"logical AND expects two arguments","messagePattern":"logical AND expects two arguments","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/filter/parser.go","lineNumber":52,"sourceCode":"\t\tif !ok {\n\t\t\treturn nil, errors.Errorf(\"unknown identifier %q\", name)\n\t\t}\n\t\tif field.Type != FieldTypeBool {\n\t\t\treturn nil, errors.Errorf(\"identifier %q is not boolean\", name)\n\t\t}\n\t\treturn &FieldPredicateCondition{Field: name}, nil\n\tcase *exprv1.Expr_ComprehensionExpr:\n\t\treturn buildComprehensionCondition(v.ComprehensionExpr, pc.schema)\n\tdefault:\n\t\treturn nil, errors.New(\"unsupported top-level expression\")\n\t}\n}\n\nfunc buildCallCondition(call *exprv1.Expr_Call, pc parseContext) (Condition, error) {\n\tswitch call.Function {\n\tcase \"_&&_\":\n\t\tif len(call.Args) != 2 {\n\t\t\treturn nil, errors.New(\"logical AND expects two arguments\")\n\t\t}\n\t\tleft, err := buildCondition(call.Args[0], pc)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tright, err := buildCondition(call.Args[1], pc)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &LogicalCondition{\n\t\t\tOperator: LogicalAnd,\n\t\t\tLeft:     left,\n\t\t\tRight:    right,\n\t\t}, nil\n\tcase \"_||_\":\n\t\tif len(call.Args) != 2 {\n\t\t\treturn nil, errors.New(\"logical OR expects two arguments\")\n\t\t}","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/usememos/memos/blob/14d757ce1fb31c78590f374bc042f8dbedbc20d7/internal/filter/parser.go#L34-L70","documentation":"Returned by buildCallCondition for the \"_&&_\" (logical AND) function when the AST call does not have exactly 2 arguments. Standard CEL always produces binary &&, so hitting this means the AST was built unusually (macro expansion edge cases or programmatic AST construction) or an internal invariant broke.","triggerScenarios":"A filter using && where the parsed Expr_Call for _&&_ carries arg count != 2 — practically rare via user input; more likely from custom ASTs or a CEL macro that desugars into _&&_ with unexpected arity.","commonSituations":"Almost never triggered by hand-written filters; can appear when generating filters programmatically or with nonstandard CEL parse options that rewrite logic ops.","solutions":["Rewrite the && expression in plain binary form (a && b, parenthesizing chains explicitly).","If generating ASTs programmatically, ensure logic operators are emitted with exactly two args.","Report as an engine bug if a plain, hand-written filter triggers it."],"exampleFix":"# before (odd grouping / generated)\n(a && b && c)\n\n# after (explicit binary chain)\n((a && b) && c)","handlingStrategy":"validation","validationCode":"// Go — parenthesize generated chains so each _&&_ is binary\n// instead of: buildAnd(a, b, c)\n// emit: ((a && b) && c)\nfunc andPair(l, r string) string { return fmt.Sprintf(\"(%s && %s)\", l, r) }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"logical AND expects two arguments\") {\n  return errors.Wrap(err, \"internal filter AST inconsistency; report with the filter text\")\n}","preventionTips":["Emit fully parenthesized binary logic when generating filters.","Round-trip generated filters through Compile in tests.","Report plain-text filters that trigger arity errors as engine bugs."],"tags":["cel","filter","parser","logical-and","go"],"backgroundTag":null,"analyzedSha":"14d757ce1fb31c78590f374bc042f8dbedbc20d7","analyzedAt":"2026-08-15T09:27:36.538Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}