{"record":{"id":"3a484d699a02fb8a","repo":"pocketbase/pocketbase","slug":"strftime-failed-to-resolve-time-value-argument","errorCode":null,"errorMessage":"[strftime] failed to resolve time-value argument: %w","messagePattern":"\\[strftime\\] failed to resolve time-value argument: %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"tools/search/token_functions.go","lineNumber":120,"sourceCode":"\t\t}\n\n\t\t// no further arguments\n\t\tif totalArgs == 1 {\n\t\t\tformatArgResult.NullFallback = NullFallbackEnforced\n\t\t\tformatArgResult.Identifier = \"strftime(\" + formatArgResult.Identifier + \")\"\n\t\t\treturn formatArgResult, nil\n\t\t}\n\n\t\t// time-value arg\n\t\t// -----------------------------------------------------------\n\t\tallowedTimeValueTokens := []fexpr.TokenType{fexpr.TokenText, fexpr.TokenIdentifier, fexpr.TokenNumber}\n\t\tif !slices.Contains(allowedTimeValueTokens, args[1].Type) {\n\t\t\treturn nil, errors.New(\"[strftime] expects the second argument to be of a valid time-value type\")\n\t\t}\n\n\t\ttimeValueArgResult, err := argTokenResolverFunc(args[1])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"[strftime] failed to resolve time-value argument: %w\", err)\n\t\t}\n\n\t\t// modifiers args\n\t\t// -----------------------------------------------------------\n\t\tresolvedModifierArgs := make([]*ResolverResult, totalArgs-2)\n\t\tfor i, arg := range args[2:] {\n\t\t\tif arg.Type != fexpr.TokenText {\n\t\t\t\treturn nil, fmt.Errorf(\"[strftime] invalid modifier argument %d - can be only string\", i)\n\t\t\t}\n\n\t\t\tresolved, err := argTokenResolverFunc(arg)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"[strftime] failed to resolve modifier argument %d: %w\", i, err)\n\t\t\t}\n\n\t\t\tresolvedModifierArgs[i] = resolved\n\t\t}\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/pocketbase/pocketbase/blob/5d217ddb50cb144d80a5d0b0bdf11b52b2c3e457/tools/search/token_functions.go#L102-L138","documentation":"Wrapped error from `strftime` when its optional second (time-value) argument fails resolution. The time-value may be a text literal, number, or field identifier; if the field resolver rejects an identifier argument (field not allowlisted/resolvable), this error wraps the underlying cause such as `failed to resolve field %q`.","triggerScenarios":"`strftime('%Y', someField) = '2026'` where `someField` is not in the resolver's allowed fields, or a dotted/JSON path that the resolver cannot resolve.","commonSituations":"Formatting a date field that was never added to the search field allowlist; typos in the field name; referencing relation fields without allowing the dotted path; schema renames not propagated to filter strings.","solutions":["Add the referenced time field to the resolver's allowed fields","Fix the field name/path spelling against the collection schema","Check the wrapped error cause to identify the exact failing identifier","Pass an explicit time literal instead of a field if the field is not meant to be filterable"],"exampleFix":"// before\nresolver := search.NewSimpleFieldResolver(\"id\")\n// filter: strftime('%Y', created) = '2026'\n// after\nresolver := search.NewSimpleFieldResolver(\"id\", \"created\")","handlingStrategy":"validation","validationCode":"// pre-check the time-value field is resolvable\nif strings.HasPrefix(timeValueArg, \"'\") == false && !isNumber(timeValueArg) {\n    if _, err := resolver.Resolve(timeValueArg); err != nil {\n        return fmt.Errorf(\"strftime time-value %q not allowed: %w\", timeValueArg, err)\n    }\n}","typeGuard":"null","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"[strftime] failed to resolve time-value\") {\n    return apiError400(\"unknown time-value field in strftime: check field name and allowlist\")\n}","preventionTips":["Allowlist every date field referenced in strftime filters","Keep filter strings updated when schema fields are renamed","Use the wrapped error to pinpoint the failing identifier","Prefer explicit ISO literals when the field is not meant to be filterable"],"tags":["pocketbase","filter","strftime","resolver","field-allowlist"],"backgroundTag":null,"analyzedSha":"5d217ddb50cb144d80a5d0b0bdf11b52b2c3e457","analyzedAt":"2026-08-15T10:06:33.165Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}