{"record":{"id":"9a4217fd4adb74a0","repo":"router-for-me/CLIProxyAPI","slug":"auth-not-found-for-auth-index-s","errorCode":null,"errorMessage":"auth not found for auth_index %s","messagePattern":"auth not found for auth_index (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/auth_callbacks.go","lineNumber":233,"sourceCode":"func (h *Host) authByIndex(authIndex string) (*coreauth.Auth, error) {\n\tauthIndex = strings.TrimSpace(authIndex)\n\tif authIndex == \"\" {\n\t\treturn nil, fmt.Errorf(\"auth_index is required\")\n\t}\n\tmanager := h.currentAuthManager()\n\tif manager == nil {\n\t\treturn nil, fmt.Errorf(\"core auth manager unavailable\")\n\t}\n\tfor _, auth := range manager.List() {\n\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}","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/auth_callbacks.go#L215-L251","documentation":"Thrown by Host.authByIndex when the auth manager is available but no registered auth entry has an Index equal to the requested auth_index after EnsureIndex() normalization. It is a straightforward lookup miss: the credential identified by that index is not currently loaded.","triggerScenarios":"Passing an auth_index that was never issued; using an index from a previous process run after auth files were deleted or reloaded with different index assignments; a stale index cached by a plugin while the auth directory changed underneath it.","commonSituations":"Auth file under auths/ was removed manually or via management API after the plugin captured the index; index is derived per-session and the process restarted; typo or truncated index string in the plugin request.","solutions":["Re-list auths via the host auth-list callback and use a currently valid index","Verify the expected auth file still exists in the configured auths directory and was reloaded","Check that the auth_index string is passed verbatim (not trimmed of meaningful characters or empty)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// refresh the index before use:\nvalid := false\nfor _, a := range host.CurrentAuthManager().List() {\n    a.EnsureIndex()\n    if a.Index == wantIndex { valid = true; break }\n}\nif !valid { /* re-list or re-acquire index */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"auth not found for auth_index\") {\n    // re-enumerate auths and retry once with a fresh index\n}","preventionTips":["Treat auth_index as ephemeral per-process; re-list after restarts or reloads","Cache index together with a fingerprint (file mtime) and invalidate on change"],"tags":["go","pluginhost","auth","lookup","stale-reference"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}