router-for-me/CLIProxyAPI · error
auth file not found for auth_index %s
Error message
auth file not found for auth_index %s
What it means
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.
Source
Thrown at internal/pluginhost/auth_callbacks.go:248
return auth, nil
}
}
return nil, fmt.Errorf("auth not found for auth_index %s", authIndex)
}
func (h *Host) authPhysicalJSONByIndex(authIndex string) (*coreauth.Auth, []byte, error) {
auth, errGet := h.authByIndex(authIndex)
if errGet != nil {
return nil, nil, errGet
}
path := strings.TrimSpace(authAttribute(auth, "path"))
if path == "" {
return nil, nil, fmt.Errorf("auth file path not found for auth_index %s", authIndex)
}
data, errRead := os.ReadFile(path)
if errRead != nil {
if os.IsNotExist(errRead) {
return nil, nil, fmt.Errorf("auth file not found for auth_index %s", authIndex)
}
return nil, nil, fmt.Errorf("failed to read auth file: %w", errRead)
}
if len(bytesTrimSpace(data)) == 0 {
return nil, nil, fmt.Errorf("auth file is empty for auth_index %s", authIndex)
}
var metadata map[string]any
if errUnmarshal := json.Unmarshal(data, &metadata); errUnmarshal != nil {
return nil, nil, fmt.Errorf("invalid auth file for auth_index %s: %w", authIndex, errUnmarshal)
}
return auth, data, nil
}
func validateHostAuthSaveRequest(req pluginapi.HostAuthSaveRequest) (string, []byte, error) {
name := strings.TrimSpace(req.Name)
if isUnsafeAuthFileName(name) {
return "", nil, fmt.Errorf("invalid auth file name")
}View on GitHub (pinned to 78f0c4079e)
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
Defensive patterns
Strategy: fallback
Validate before calling
// pre-check the backing file exists:
if p := authAttribute(auth, "path"); p != "" {
if _, statErr := os.Stat(p); statErr != nil {
// handle missing file before calling the callback
}
} Try / catch
if err != nil && strings.Contains(err.Error(), "auth file not found") {
// trigger re-login / reload and drop the stale record
} Prevention
- Persist the auths directory on a volume across restarts
- Delete auths through the management API so the registry stays consistent
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- auth file path not found for auth_index %s
- failed to read auth file: %w
- auth file is empty for auth_index %s
- failed to write auth file: %w
- core auth manager unavailable
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/172293a095b10c68.
Report an issue: GitHub.