{"record":{"id":"c319a7beaa35e075","repo":"pocketbase/pocketbase","slug":"now-w","errorCode":null,"errorMessage":"@now: %w","messagePattern":"@now: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/search/identifier_macros.go","lineNumber":21,"sourceCode":"import (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/pocketbase/pocketbase/tools/types\"\n)\n\n// note: used primarily for the tests\nvar timeNow = func() time.Time {\n\treturn time.Now()\n}\n\nvar identifierMacros = map[string]func() (any, error){\n\t\"@now\": func() (any, error) {\n\t\ttoday := timeNow().UTC()\n\n\t\td, err := types.ParseDateTime(today)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"@now: %w\", err)\n\t\t}\n\n\t\treturn d.String(), nil\n\t},\n\t\"@yesterday\": func() (any, error) {\n\t\tyesterday := timeNow().UTC().AddDate(0, 0, -1)\n\n\t\td, err := types.ParseDateTime(yesterday)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"@yesterday: %w\", err)\n\t\t}\n\n\t\treturn d.String(), nil\n\t},\n\t\"@tomorrow\": func() (any, error) {\n\t\ttomorrow := timeNow().UTC().AddDate(0, 0, 1)\n\n\t\td, err := types.ParseDateTime(tomorrow)","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/pocketbase/pocketbase/blob/5d217ddb50cb144d80a5d0b0bdf11b52b2c3e457/tools/search/identifier_macros.go#L3-L39","documentation":"Thrown by the `@now` filter macro in tools/search/identifier_macros.go when `types.ParseDateTime` fails on the current UTC time. Macros like `@now` are expanded when a filter string (e.g. `created <= @now`) is resolved by the search filter builder. Because the input always comes from `time.Now().UTC()`, this error is defensive and effectively unreachable unless the datetime parser regresses or is changed.","triggerScenarios":"Resolving a collection/API filter containing the `@now` identifier (e.g. `filter=created<=%40now`) AND `types.ParseDateTime` failing on a well-formed `time.Time` value.","commonSituations":"Custom forks or version upgrades that change `types.ParseDateTime` accepted formats; essentially never fires on stock PocketBase builds.","solutions":["Confirm you are on a stock, up-to-date PocketBase release (the macro path is time-based, not user-input based)","Replace `@now` with an explicit datetime literal (e.g. `2026-01-01 00:00:00.000Z`) to bypass the macro","If it reproduces on stock code, report it as a regression in types.ParseDateTime with the exact timestamp"],"exampleFix":"// before\nfilter := \"created <= @now\"\n// after\nfilter := \"created <= '2026-08-15 00:00:00.000Z'\"","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"// when resolving a filter containing macros\nresult, err := search.FilterData(\"created <= @now\", resolver)\nif err != nil {\n    if strings.Contains(err.Error(), \"@now:\") {\n        // macro expansion failed; fall back to explicit literal\n        result, err = search.FilterData(\"created <= '\"+time.Now().UTC().Format(\"2006-01-02 15:04:05.000Z\")+\"'\", resolver)\n    }\n    if err != nil { return err }\n}","preventionTips":["Keep PocketBase core and tools/types packages version-aligned","Prefer explicit datetime literals over macros in stored/permanent filters","Treat macro errors as regression signals — they do not indicate bad user input"],"tags":["pocketbase","filter","macro","datetime","search"],"backgroundTag":null,"analyzedSha":"5d217ddb50cb144d80a5d0b0bdf11b52b2c3e457","analyzedAt":"2026-08-15T10:06:33.165Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}