{"record":{"id":"172293a095b10c68","repo":"router-for-me/CLIProxyAPI","slug":"auth-file-not-found-for-auth-index-s","errorCode":null,"errorMessage":"auth file not found for auth_index %s","messagePattern":"auth file not found for auth_index (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/auth_callbacks.go","lineNumber":248,"sourceCode":"\t\t\treturn auth, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"auth not found for auth_index %s\", authIndex)\n}\n\nfunc (h *Host) authPhysicalJSONByIndex(authIndex string) (*coreauth.Auth, []byte, error) {\n\tauth, errGet := h.authByIndex(authIndex)\n\tif errGet != nil {\n\t\treturn nil, nil, errGet\n\t}\n\tpath := strings.TrimSpace(authAttribute(auth, \"path\"))\n\tif path == \"\" {\n\t\treturn nil, nil, fmt.Errorf(\"auth file path not found for auth_index %s\", authIndex)\n\t}\n\tdata, errRead := os.ReadFile(path)\n\tif errRead != nil {\n\t\tif os.IsNotExist(errRead) {\n\t\t\treturn nil, nil, fmt.Errorf(\"auth file not found for auth_index %s\", authIndex)\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"failed to read auth file: %w\", errRead)\n\t}\n\tif len(bytesTrimSpace(data)) == 0 {\n\t\treturn nil, nil, fmt.Errorf(\"auth file is empty for auth_index %s\", authIndex)\n\t}\n\tvar metadata map[string]any\n\tif errUnmarshal := json.Unmarshal(data, &metadata); errUnmarshal != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid auth file for auth_index %s: %w\", authIndex, errUnmarshal)\n\t}\n\treturn auth, data, nil\n}\n\nfunc validateHostAuthSaveRequest(req pluginapi.HostAuthSaveRequest) (string, []byte, error) {\n\tname := strings.TrimSpace(req.Name)\n\tif isUnsafeAuthFileName(name) {\n\t\treturn \"\", nil, fmt.Errorf(\"invalid auth file name\")\n\t}","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/auth_callbacks.go#L230-L266","documentation":"Thrown by Host.authPhysicalJSONByIndex when os.ReadFile fails with os.IsNotExist on the auth record's stored path. The registry still lists the auth, but its backing JSON file has been deleted from disk.","triggerScenarios":"Someone deleted or moved the file under auths/ after the manager loaded it; the auth directory was switched (config change to a different auth dir) while records still point at old paths; a container redeploy lost a non-persistent volume.","commonSituations":"Manual cleanup of auths/*.json without triggering reload; Docker/Kubernetes deployment without a persistent volume for auths; config hot-reload changing auth-directory between load and read.","solutions":["Restore or re-create the missing auth file (re-run the OAuth/login flow for that provider)","Trigger an auth reload so the manager drops the stale record instead of serving it","Persist the auths directory across restarts (volume mount) in containerized deployments"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// pre-check the backing file exists:\nif p := authAttribute(auth, \"path\"); p != \"\" {\n    if _, statErr := os.Stat(p); statErr != nil {\n        // handle missing file before calling the callback\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"auth file not found\") {\n    // trigger re-login / reload and drop the stale record\n}","preventionTips":["Persist the auths directory on a volume across restarts","Delete auths through the management API so the registry stays consistent"],"tags":["go","pluginhost","auth","filesystem","file-not-found"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}