router-for-me/CLIProxyAPI · error

decode host auth list request: %w

Error message

decode host auth list request: %w

What it means

The host-side auth.list RPC callback received a request payload that is not valid JSON (or not a JSON object) and json.Unmarshal into map[string]any failed. The callback rejects the call before listing auth files; this is the plugin-to-host boundary validating its input.

Source

Thrown at internal/pluginhost/auth_callbacks.go:58

	h.mu.Unlock()
}

func (h *Host) currentAuthManager() *coreauth.Manager {
	if h == nil {
		return nil
	}
	h.mu.Lock()
	manager := h.authManager
	h.mu.Unlock()
	return manager
}

func (h *Host) callHostAuthList(ctx context.Context, request []byte) ([]byte, error) {
	_ = ctx
	if len(bytesTrimSpace(request)) > 0 {
		var req map[string]any
		if errUnmarshal := json.Unmarshal(request, &req); errUnmarshal != nil {
			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")

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Capture the exact payload bytes the plugin sends for the auth list call and validate them with a JSON linter
  2. Update the plugin to use the current plugin SDK/protocol (empty object {} is valid; so is an empty body)
  3. If using a custom transport, verify framing/length prefixes so payloads are not truncated
  4. Restart the plugin process to re-establish a clean IPC channel if the stream got desynchronized
Defensive patterns

Strategy: validation

Validate before calling

// In the plugin, validate before sending the RPC:
func validAuthListPayload(b []byte) bool {
    if len(bytes.TrimSpace(b)) == 0 { return true } // empty is allowed
    var probe map[string]any
    return json.Unmarshal(b, &probe) == nil
}

Prevention

When it happens

Trigger: A plugin invoking the host 'auth list' RPC with a malformed payload — non-JSON bytes, a JSON array/scalar instead of an object, or a truncated frame from a broken IPC/stdio transport.

Common situations: Hand-written or third-party plugin sending the wrong RPC frame; plugin SDK version drift changing the wire format; stdio pipe corruption or partial writes between plugin process and host.

Related errors


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/17282bdb69f35abc. Report an issue: GitHub.