router-for-me/CLIProxyAPI · error

decode host auth get request: %w

Error message

decode host auth get request: %w

What it means

The host-side auth.get RPC callback could not decode its request into rpcHostAuthGetRequest — the payload is not valid JSON or has the wrong shape (e.g. AuthIndex typed incorrectly). The call fails before any auth lookup happens.

Source

Thrown at internal/pluginhost/auth_callbacks.go:72

	_ = 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")
	}
	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,

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Log the raw request bytes at the RPC boundary and confirm they form {"auth_index": "..."}
  2. Regenerate/align the plugin against the current pluginapi types for the auth get request
  3. Use the plugin SDK's client helpers instead of hand-building RPC frames
  4. Re-establish the plugin process/channel if frames are being truncated
Defensive patterns

Strategy: validation

Validate before calling

// Plugin side, build and check the request before the call:
payload, err := json.Marshal(map[string]string{"auth_index": idx})
if err != nil { return err }
if idx == "" { return errors.New("auth_index required") }

Type guard

func isAuthGetRequestValid(b []byte) bool {
    var r struct{ AuthIndex string `json:"auth_index"` }
    return json.Unmarshal(b, &r) == nil && strings.TrimSpace(r.AuthIndex) != ""
}

Prevention

When it happens

Trigger: A plugin calling the host 'auth get' RPC with malformed JSON, a missing/misnamed auth_index field serialized under a different key, or auth_index sent as a non-string type.

Common situations: Plugin SDK version mismatch (field renamed in the protocol); plugin constructing the request by hand with a typo; truncated RPC frame over the transport.

Related errors


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