router-for-me/CLIProxyAPI · error
auth path is empty
Error message
auth path is empty
What it means
Thrown by Host.buildAuthFromFileData when the path argument trims to empty. The builder needs a concrete file path to derive the auth identity (authIDForPath) and to optionally read data; an empty path is a programming-error-level input.
Source
Thrown at internal/pluginhost/auth_callbacks.go:307
dst = abs
}
}
auth, errBuild := h.buildAuthFromFileData(dst, data)
if errBuild != nil {
return "", errBuild
}
if errWrite := os.WriteFile(dst, data, 0o600); errWrite != nil {
return "", fmt.Errorf("failed to write auth file: %w", errWrite)
}
if errUpsert := h.upsertAuthRecord(ctx, auth); errUpsert != nil {
return "", errUpsert
}
return dst, nil
}
func (h *Host) buildAuthFromFileData(path string, data []byte) (*coreauth.Auth, error) {
if strings.TrimSpace(path) == "" {
return nil, fmt.Errorf("auth path is empty")
}
if data == nil {
var errRead error
data, errRead = os.ReadFile(path)
if errRead != nil {
return nil, fmt.Errorf("failed to read auth file: %w", errRead)
}
}
metadata := make(map[string]any)
if errUnmarshal := json.Unmarshal(data, &metadata); errUnmarshal != nil {
return nil, fmt.Errorf("invalid auth file: %w", errUnmarshal)
}
provider, _ := metadata["type"].(string)
if strings.TrimSpace(provider) == "" {
provider = "unknown"
}
label := provider
if email, ok := metadata["email"].(string); ok && strings.TrimSpace(email) != "" {View on GitHub (pinned to 78f0c4079e)
Solutions
- Ensure the destination path is built from a non-empty directory plus base name before calling build
- Guard upstream: reject empty paths at the entry point (saveAuthFile already checks auth dir separately)
Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(path) == "" {
return errors.New("empty auth path")
} Prevention
- Build paths as filepath.Join(dir, filepath.Base(name)) from validated non-empty parts
- Assert non-empty path in unit tests covering the save flow
When it happens
Trigger: Caller passes an empty/unset path string, typically when a save flow computed the destination from an empty auth-dir or an upstream field was never populated.
Common situations: Internal misuse of the build API; a code path where resolvedAuthDir returned "" and Join produced an empty result; refactoring that dropped the path argument.
Related errors
- invalid auth file name
- auth file name must end with .json
- json is required
- invalid auth json: %w
- invalid auth weight: %w
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/efc45a35bb8b23b3.
Report an issue: GitHub.