{"record":{"id":"a1070e0f32bdfeb8","repo":"usememos/memos","slug":"timestamp-expects-one-argument","errorCode":null,"errorMessage":"timestamp() expects one argument","messagePattern":"timestamp\\(\\) expects one argument","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/filter/parser.go","lineNumber":593,"sourceCode":"\t\t\treturn left / right, true, nil\n\t\tcase \"_%_\":\n\t\t\tif right == 0 {\n\t\t\t\treturn 0, false, errors.New(\"modulo by zero\")\n\t\t\t}\n\t\t\treturn left % right, true, nil\n\t\tdefault:\n\t\t\treturn 0, false, errors.Errorf(\"unsupported arithmetic operator %q\", call.Function)\n\t\t}\n\tdefault:\n\t\treturn 0, false, nil\n\t}\n}\n\n// evaluateTimestamp folds timestamp(\"RFC3339\") and timestamp(<epoch int>) into\n// Unix epoch seconds.\nfunc evaluateTimestamp(call *exprv1.Expr_Call) (int64, bool, error) {\n\tif len(call.Args) != 1 {\n\t\treturn 0, false, errors.New(\"timestamp() expects one argument\")\n\t}\n\tvalue, err := getConstValue(call.Args[0])\n\tif err != nil {\n\t\treturn 0, false, errors.Wrap(err, \"timestamp() only supports literal arguments\")\n\t}\n\tswitch v := value.(type) {\n\tcase string:\n\t\tts, err := time.Parse(time.RFC3339, v)\n\t\tif err != nil {\n\t\t\treturn 0, false, errors.Wrap(err, \"invalid timestamp literal\")\n\t\t}\n\t\treturn ts.Unix(), true, nil\n\tcase int64:\n\t\treturn v, true, nil\n\tdefault:\n\t\treturn 0, false, errors.New(\"timestamp() argument must be an RFC3339 string or epoch int\")\n\t}\n}","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/usememos/memos/blob/14d757ce1fb31c78590f374bc042f8dbedbc20d7/internal/filter/parser.go#L575-L611","documentation":"evaluateTimestamp folds timestamp(\"RFC3339\") and timestamp(<epoch int>) into Unix seconds so filters can compare against created_ts/updated_ts. The helper first requires exactly one argument; any other count is rejected before the value is inspected.","triggerScenarios":"Filters like created_ts > timestamp() or created_ts > timestamp(\"2024-01-01T00:00:00Z\", \"UTC\") — zero or multiple arguments to timestamp().","commonSituations":"Adding a timezone second argument by analogy with other date libraries; template placeholders that expand to nothing when unset.","solutions":["Pass exactly one RFC3339 string or epoch integer: timestamp(\"2024-01-01T00:00:00Z\")","Encode timezone offsets inside the RFC3339 string (+02:00) instead of extra args","For epoch times, pass the raw integer: timestamp(1704067200)"],"exampleFix":"// before\ncreated_ts > timestamp(\"2024-01-01T00:00:00Z\", \"UTC\")\n\n// after\ncreated_ts > timestamp(\"2024-01-01T00:00:00Z\")","handlingStrategy":"validation","validationCode":"// TS: build a valid timestamp() call\nconst iso = new Date(cfg.since).toISOString(); // RFC3339 by construction\nif (Number.isNaN(Date.parse(iso))) throw new Error('invalid date');\nconst filter = `created_ts > timestamp(\"${iso}\")`;","typeGuard":"const isRfc3339 = (s: string): boolean => !Number.isNaN(Date.parse(s)) && /T\\d\\d:\\d\\d:\\d\\d/.test(s);","tryCatchPattern":null,"preventionTips":["Always emit exactly one argument to timestamp()","Generate RFC3339 strings with date.toISOString() / time.Format(time.RFC3339)","Encode time zones inside the timestamp string, not as extra args"],"tags":["cel","timestamp","arity","filter"],"backgroundTag":null,"analyzedSha":"14d757ce1fb31c78590f374bc042f8dbedbc20d7","analyzedAt":"2026-08-15T09:27:36.538Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}