{"record":{"id":"395b8249d77fb60e","repo":"microsoft/typescript-go","slug":"32602","errorCode":"-32602","errorMessage":"%w: expected no params, got %s","messagePattern":"%w: expected no params, got (.+?)","errorType":"error_code","errorClass":"ErrorCode","httpStatus":null,"severity":"error","filePath":"internal/lsp/lsproto/lsp.go","lineNumber":250,"sourceCode":"//\n// A [NoParams] method must be given no params; every other method must be given\n// params as an object or array. A violation returns [ErrorCodeInvalidParams].\nfunc UnmarshalParams[T any](req *RequestMessage) (T, error) {\n\tvar params T\n\tvar raw json.Value\n\tif req.Params != nil {\n\t\tv, ok := req.Params.(json.Value)\n\t\tif !ok {\n\t\t\treturn params, fmt.Errorf(\"%w: unexpected params type %T\", ErrorCodeInvalidParams, req.Params)\n\t\t}\n\t\traw = v\n\t}\n\n\t// params is the zero value of T; this asserts on its type, i.e. whether the\n\t// method was declared with NoParams.\n\tif _, declaresNoParams := any(params).(NoParams); declaresNoParams {\n\t\tif len(raw) != 0 {\n\t\t\treturn params, fmt.Errorf(\"%w: expected no params, got %s\", ErrorCodeInvalidParams, raw)\n\t\t}\n\t\treturn params, nil\n\t}\n\n\t// The base protocol defines params as `array | object`; reject anything else\n\t// (absent, null, or a scalar).\n\tif k := raw.Kind(); k != '{' && k != '[' {\n\t\treturn params, fmt.Errorf(\"%w: params must be an object or array\", ErrorCodeInvalidParams)\n\t}\n\tif err := json.Unmarshal(raw, &params); err != nil {\n\t\treturn params, fmt.Errorf(\"%w: %w\", ErrorCodeInvalidParams, err)\n\t}\n\treturn params, nil\n}\n\ntype Null struct{}\n\nfunc (Null) UnmarshalJSONFrom(dec *json.Decoder) error {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/lsp/lsproto/lsp.go#L232-L268","documentation":"Returned by lsproto.UnmarshalParams when a method whose params type is the marker NoParams (declared to take no parameters, e.g. shutdown or the workspace/*/refresh requests) arrives with a non-empty params payload. The base protocol lets params be optional, so this library enforces the declaration at dispatch time and wraps the error with ErrorCodeInvalidParams (-32602) so it maps to a standard JSON-RPC error response.","triggerScenarios":"A client sends \"params\": {} or any params value with the shutdown request, or attaches params to a notification whose Go handler dispatches via UnmarshalParams[lsproto.NoParams]. Line 248-251 checks the type assertion any(params).(NoParams) and rejects any raw bytes with len != 0.","commonSituations":"Client frameworks that always inject an empty params object into every request; test harnesses templating requests with a fixed params key; middleware that rewrites absent params to {} or null; protocol libraries that cannot express parameterless methods.","solutions":["Omit the params member entirely from the JSON-RPC message for methods declared NoParams.","If your client framework cannot omit params, special-case empty objects to drop the key before sending.","When writing server handlers, only dispatch methods via UnmarshalParams[lsproto.NoParams] when the spec truly has no params; otherwise accept the empty object shape your client emits."],"exampleFix":"// before\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"shutdown\",\"params\":{}}\n// after\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"shutdown\"}","handlingStrategy":"validation","validationCode":"// drop params entirely for parameterless methods before writing the frame\nvar noParamsMethods = map[string]bool{\n    \"shutdown\": true,\n    \"workspace/semanticTokens/refresh\": true,\n    \"workspace/inlayHint/refresh\": true,\n    \"workspace/codeLens/refresh\": true,\n    \"workspace/diagnostic/refresh\": true,\n    \"exit\": true,\n}\n\nfunc frame(method string, params any) map[string]any {\n    m := map[string]any{\"jsonrpc\": \"2.0\", \"method\": method}\n    if !noParamsMethods[method] {\n        m[\"params\"] = params\n    }\n    return m\n}","typeGuard":"func isNoParamsMethod(method string) bool {\n    switch method {\n    case \"shutdown\", \"exit\", \"workspace/semanticTokens/refresh\", \"workspace/inlayHint/refresh\", \"workspace/codeLens/refresh\", \"workspace/diagnostic/refresh\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"// server-side dispatcher: map -32602 'expected no params' to a clean response\nif errors.Is(err, lsproto.ErrorCodeInvalidParams) && strings.Contains(err.Error(), \"expected no params\") {\n    return sendError(id, fmt.Errorf(\"%w: method takes no parameters\", lsproto.ErrorCodeInvalidParams))\n}","preventionTips":["Omit the params member for methods declared without parameters; do not send {} or null.","Special-case empty params objects in generic client frameworks and strip them.","Keep a list of NoParams methods beside your request-building code."],"tags":["lsp","jsonrpc","validation","protocol"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}