router-for-me/CLIProxyAPI · error
auth_index is required
Error message
auth_index is required
What it means
The host's auth.get callback requires a non-empty auth_index; the request decoded but auth_index was empty or only whitespace, so the callback refuses to look up anything.
Source
Thrown at internal/pluginhost/auth_callbacks.go:76
return nil, fmt.Errorf("decode host auth list request: %w", errUnmarshal)
}
}
entries, errList := h.listAuthFiles()
if errList != nil {
return nil, errList
}
return marshalRPCResult(rpcHostAuthListResponse{Files: entries})
}
func (h *Host) callHostAuthGet(ctx context.Context, request []byte) ([]byte, error) {
_ = ctx
var req rpcHostAuthGetRequest
if errUnmarshal := json.Unmarshal(request, &req); errUnmarshal != nil {
return nil, fmt.Errorf("decode host auth get request: %w", errUnmarshal)
}
authIndex := strings.TrimSpace(req.AuthIndex)
if authIndex == "" {
return nil, fmt.Errorf("auth_index is required")
}
auth, rawJSON, errGet := h.authPhysicalJSONByIndex(authIndex)
if errGet != nil {
return nil, errGet
}
name := strings.TrimSpace(auth.FileName)
if name == "" {
name = strings.TrimSpace(auth.ID)
}
path := strings.TrimSpace(authAttribute(auth, "path"))
return marshalRPCResult(rpcHostAuthGetResponse{
AuthIndex: authIndex,
Name: name,
Path: path,
JSON: json.RawMessage(rawJSON),
})
}
View on GitHub (pinned to 78f0c4079e)
Solutions
- In the plugin, list auth files first (auth.list) and pass a concrete AuthIndex from the result
- Fail fast in the plugin when the derived auth_index is empty instead of calling the host
- Check that the plugin's request struct sets the auth_index json tag correctly
Example fix
// before
req := HostAuthGetRequest{} // AuthIndex empty
resp, err := host.AuthGet(ctx, req)
// after
if strings.TrimSpace(idx) == "" {
return errors.New("no auth_index available")
}
resp, err := host.AuthGet(ctx, HostAuthGetRequest{AuthIndex: idx}) Defensive patterns
Strategy: validation
Validate before calling
idx := strings.TrimSpace(entry.AuthIndex)
if idx == "" {
return errors.New("no auth_index from list result; nothing to get")
}
resp, err := hostClient.AuthGet(ctx, HostAuthGetRequest{AuthIndex: idx}) Prevention
- Treat an empty auth list as 'stop', never 'use empty index'
- Mark required RPC fields in plugin structs and check them before send
- Log the originating RPC payload when validation fails at the host
When it happens
Trigger: Plugin calls host auth get with auth_index omitted, empty string, or whitespace — e.g. it enumerated auth files, got no entries, and passed through an empty index unchecked.
Common situations: Plugin logic that derives auth_index from a previous list call returning nothing; default/zero-value struct serialized without omitzero; plugin assumes an implicit 'first' auth which the protocol does not have.
Related errors
- decode host auth list request: %w
- decode host auth get request: %w
- decode host auth get runtime request: %w
- auth runtime info not found for auth_index %s
- decode host auth save request: %w
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/5868d555ee320076.
Report an issue: GitHub.