router-for-me/CLIProxyAPI · error

decode host auth get runtime request: %w

Error message

decode host auth get runtime request: %w

What it means

The host-side auth.get_runtime RPC callback failed to decode its request into rpcHostAuthGetRequest — invalid JSON or wrong field types. The runtime-info call is rejected before the auth manager is consulted.

Source

Thrown at internal/pluginhost/auth_callbacks.go:99

	}
	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),
	})
}

func (h *Host) callHostAuthGetRuntime(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 runtime request: %w", errUnmarshal)
	}
	authIndex := strings.TrimSpace(req.AuthIndex)
	if authIndex == "" {
		return nil, fmt.Errorf("auth_index is required")
	}
	auth, errGet := h.authByIndex(authIndex)
	if errGet != nil {
		return nil, errGet
	}
	entry := h.buildHostAuthFileEntry(auth)
	if entry == nil {
		return nil, fmt.Errorf("auth runtime info not found for auth_index %s", authIndex)
	}
	return marshalRPCResult(pluginapi.HostAuthGetRuntimeResponse{Auth: *entry})
}

func (h *Host) callHostAuthSave(ctx context.Context, request []byte) ([]byte, error) {
	var req pluginapi.HostAuthSaveRequest

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Validate the exact bytes sent for the runtime call (must decode into an object with a string auth_index)
  2. Align plugin and host pluginapi versions and rebuild the plugin
  3. Use SDK helpers for the RPC; restart the plugin process if the channel is desynced
Defensive patterns

Strategy: validation

Validate before calling

payload, err := json.Marshal(map[string]string{"auth_index": idx})
if err != nil { return err }
if idx == "" { return errors.New("auth_index required for runtime info") }

Prevention

When it happens

Trigger: Plugin calls the host 'auth get runtime' RPC with a payload that is not valid JSON or where auth_index has the wrong type/name; identical failure class to auth.get decode but on the runtime variant.

Common situations: Plugin SDK protocol drift; hand-built RPC frames with typos; partially-written frames over stdio/socket transport.

Related errors


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