{"record":{"id":"ccfc45f05874c2e6","repo":"router-for-me/CLIProxyAPI","slug":"invalid-field-path-s","errorCode":null,"errorMessage":"invalid field path: %s","messagePattern":"invalid field path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"internal/api/handlers/management/auth_files_fields.go","lineNumber":354,"sourceCode":"\tif path == \"\" {\n\t\treturn \"\"\n\t}\n\tif idx := strings.Index(path, \".\"); idx >= 0 {\n\t\treturn strings.TrimSpace(path[:idx])\n\t}\n\treturn path\n}\n\nfunc setAuthFileMetadataValue(metadata map[string]any, path string, value any) error {\n\tif metadata == nil {\n\t\treturn fmt.Errorf(\"metadata is nil\")\n\t}\n\tparts := strings.Split(path, \".\")\n\tcurrent := metadata\n\tfor i, rawPart := range parts {\n\t\tpart := strings.TrimSpace(rawPart)\n\t\tif part == \"\" {\n\t\t\treturn fmt.Errorf(\"invalid field path: %s\", path)\n\t\t}\n\t\tif i == len(parts)-1 {\n\t\t\tcurrent[part] = value\n\t\t\treturn nil\n\t\t}\n\t\tnext, ok := current[part].(map[string]any)\n\t\tif !ok {\n\t\t\tnext = make(map[string]any)\n\t\t\tcurrent[part] = next\n\t\t}\n\t\tcurrent = next\n\t}\n\treturn nil\n}\n\nfunc applyAuthFileHeadersPatch(auth *coreauth.Auth, value any) {\n\tif auth == nil {\n\t\treturn","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/api/handlers/management/auth_files_fields.go#L336-L372","documentation":"The dotted field path passed to setAuthFileMetadataValue contains an empty segment — a leading dot, trailing dot, double dot, or whitespace-only segment after trimming (e.g. \".weight\", \"a..b\", \"labels. \"). The helper walks segments to nest maps and cannot address an unnamed key, so it rejects the path with the offending string included.","triggerScenarios":"PATCHing an auth-file field whose request path string has a typo like \"providers..gemini\" or \"weight.\"; client code building the path dynamically by joining empty parts with '.'; payloads where whitespace snuck into the key.","commonSituations":"Hand-written curl/PowerShell requests with dot typos; template strings interpolating an empty variable into the path; clients porting from a different nesting separator producing double dots.","solutions":["Look at the %s path echoed in the error and remove the stray dot or whitespace segment","If building paths programmatically, filter out empty parts before joining with '.'","Add client-side validation rejecting paths with empty segments","Retry the PATCH with the corrected path"],"exampleFix":"// before\n{\"path\": \"providers..gemini\", \"value\": 3}\n// after\n{\"path\": \"providers.gemini\", \"value\": 3}","handlingStrategy":"validation","validationCode":"for _, seg := range strings.Split(path, \".\") {\n    if strings.TrimSpace(seg) == \"\" {\n        return fmt.Errorf(\"rejecting field path %q: empty segment\", path)\n    }\n}","typeGuard":"func isValidFieldPath(path string) bool {\n    if strings.TrimSpace(path) == \"\" { return false }\n    for _, seg := range strings.Split(path, \".\") {\n        if strings.TrimSpace(seg) == \"\" { return false }\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["Build dotted paths by joining only non-empty parts","Client-side validate paths against a ^[\\w-]+(\\.[\\w-]+)*$ style pattern"],"tags":["validation","field-path","user-input"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}