{"record":{"id":"a02bc1721e89f22c","repo":"router-for-me/CLIProxyAPI","slug":"auth-file-path-not-found-for-auth-index-s","errorCode":null,"errorMessage":"auth file path not found for auth_index %s","messagePattern":"auth file path not found for auth_index (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/auth_callbacks.go","lineNumber":243,"sourceCode":"\t\tif auth == nil {\n\t\t\tcontinue\n\t\t}\n\t\tauth.EnsureIndex()\n\t\tif auth.Index == authIndex {\n\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","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/auth_callbacks.go#L225-L261","documentation":"Thrown by Host.authPhysicalJSONByIndex when the auth entry is found but its 'path' attribute (authAttribute(auth, \"path\")) is empty. The host needs the on-disk file path to return the raw JSON; an auth record without a path means it was registered in memory or built from data whose source path was not recorded.","triggerScenarios":"Calling the physical-JSON callback for an auth created via upsertAuthRecord/buildAuthFromFileData where the path could not be mapped to an auth ID, or an auth injected programmatically (OAuth flow in memory) that never had a filesystem backing path.","commonSituations":"Auth acquired via interactive OAuth that has not yet been persisted; auth records modified by external code that dropped the path attribute; auth file moved/renamed outside the watcher so the stale record no longer carries a resolvable path.","solutions":["Ensure the auth was persisted to the auths directory so its record carries a real file path","Trigger a config/auth reload or restart so records are rebuilt from files with correct paths","For programmatic auths, register them with a concrete file path instead of in-memory data"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"auth file path not found\") {\n    // fall back to manager metadata instead of physical JSON\n}","preventionTips":["Persist auths to the auths directory so records carry file paths","Avoid moving/renaming auth files outside the watcher"],"tags":["go","pluginhost","auth","filesystem","metadata"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}