{"record":{"id":"ace7170f4de51b74","repo":"router-for-me/CLIProxyAPI","slug":"decode-host-auth-get-request-w","errorCode":null,"errorMessage":"decode host auth get request: %w","messagePattern":"decode host auth get request: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/auth_callbacks.go","lineNumber":72,"sourceCode":"\t_ = ctx\n\tif len(bytesTrimSpace(request)) > 0 {\n\t\tvar req map[string]any\n\t\tif errUnmarshal := json.Unmarshal(request, &req); errUnmarshal != nil {\n\t\t\treturn nil, fmt.Errorf(\"decode host auth list request: %w\", errUnmarshal)\n\t\t}\n\t}\n\tentries, errList := h.listAuthFiles()\n\tif errList != nil {\n\t\treturn nil, errList\n\t}\n\treturn marshalRPCResult(rpcHostAuthListResponse{Files: entries})\n}\n\nfunc (h *Host) callHostAuthGet(ctx context.Context, request []byte) ([]byte, error) {\n\t_ = ctx\n\tvar req rpcHostAuthGetRequest\n\tif errUnmarshal := json.Unmarshal(request, &req); errUnmarshal != nil {\n\t\treturn nil, fmt.Errorf(\"decode host auth get request: %w\", errUnmarshal)\n\t}\n\tauthIndex := strings.TrimSpace(req.AuthIndex)\n\tif authIndex == \"\" {\n\t\treturn nil, fmt.Errorf(\"auth_index is required\")\n\t}\n\tauth, rawJSON, errGet := h.authPhysicalJSONByIndex(authIndex)\n\tif errGet != nil {\n\t\treturn nil, errGet\n\t}\n\tname := strings.TrimSpace(auth.FileName)\n\tif name == \"\" {\n\t\tname = strings.TrimSpace(auth.ID)\n\t}\n\tpath := strings.TrimSpace(authAttribute(auth, \"path\"))\n\treturn marshalRPCResult(rpcHostAuthGetResponse{\n\t\tAuthIndex: authIndex,\n\t\tName:      name,\n\t\tPath:      path,","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/auth_callbacks.go#L54-L90","documentation":"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.","triggerScenarios":"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.","commonSituations":"Plugin SDK version mismatch (field renamed in the protocol); plugin constructing the request by hand with a typo; truncated RPC frame over the transport.","solutions":["Log the raw request bytes at the RPC boundary and confirm they form {\"auth_index\": \"...\"}","Regenerate/align the plugin against the current pluginapi types for the auth get request","Use the plugin SDK's client helpers instead of hand-building RPC frames","Re-establish the plugin process/channel if frames are being truncated"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Plugin side, build and check the request before the call:\npayload, err := json.Marshal(map[string]string{\"auth_index\": idx})\nif err != nil { return err }\nif idx == \"\" { return errors.New(\"auth_index required\") }","typeGuard":"func isAuthGetRequestValid(b []byte) bool {\n    var r struct{ AuthIndex string `json:\"auth_index\"` }\n    return json.Unmarshal(b, &r) == nil && strings.TrimSpace(r.AuthIndex) != \"\"\n}","tryCatchPattern":null,"preventionTips":["Use the plugin SDK request types, not hand-rolled maps","Integration-test every RPC a plugin uses against the host before release","Pin pluginapi versions in go.mod"],"tags":["plugin","rpc","json","validation"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}