router-for-me/CLIProxyAPI · error
auth file path not found for auth_index %s
Error message
auth file path not found for auth_index %s
What it means
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.
Source
Thrown at internal/pluginhost/auth_callbacks.go:243
if auth == nil {
continue
}
auth.EnsureIndex()
if auth.Index == authIndex {
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
}
View on GitHub (pinned to 78f0c4079e)
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
Defensive patterns
Strategy: validation
Try / catch
if err != nil && strings.Contains(err.Error(), "auth file path not found") {
// fall back to manager metadata instead of physical JSON
} Prevention
- Persist auths to the auths directory so records carry file paths
- Avoid moving/renaming auth files outside the watcher
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- auth file 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/a02bc1721e89f22c.
Report an issue: GitHub.