{"record":{"id":"d76d61d0e4e14f70","repo":"microsoft/typescript-go","slug":"missing-required-properties-s","errorCode":null,"errorMessage":"missing required properties: %s","messagePattern":"missing required properties: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lsp/lsproto/lsp.go","lineNumber":96,"sourceCode":"\ntype HasLocation interface {\n\tGetLocation() Location\n}\n\ntype URI string // !!!\n\ntype Method string\n\nfunc errNotObject(k json.Kind) error {\n\treturn fmt.Errorf(\"expected object start, but encountered %v\", k)\n}\n\nfunc errNull(field string) error {\n\treturn fmt.Errorf(\"null value is not allowed for field %q\", field)\n}\n\nfunc errMissing(props []string) error {\n\treturn fmt.Errorf(\"missing required properties: %s\", strings.Join(props, \", \"))\n}\n\nfunc errInvalidKind(typeName string, got json.Kind) error {\n\treturn fmt.Errorf(\"invalid %s: got %v\", typeName, got)\n}\n\nfunc errInvalidValue(typeName string, data []byte) error {\n\treturn fmt.Errorf(\"invalid %s: %s\", typeName, data)\n}\n\nfunc errLiteralMismatch(typeName string, expected string, got []byte) error {\n\treturn fmt.Errorf(\"expected %s value %s, got %s\", typeName, expected, got)\n}\n\nfunc assertOnlyOne(message string, count int) {\n\tif count != 1 {\n\t\tpanic(message)\n\t}","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/lsp/lsproto/lsp.go#L78-L114","documentation":"Thrown by the lsproto struct decoder when an inbound JSON-RPC message's params object decodes successfully but is missing one or more fields the LSP spec marks required. This is the code-generated TypeScript-Go LSP server's strict validation: every struct field tagged required in lsp_generated.go must appear in the payload, or UnmarshalParams / json.Unmarshal fails with this error before dispatch.","triggerScenarios":"A client sends a request or notification whose params omit a required field, e.g. textDocument/didOpen without textDocument, textDocument/rename without newName, or initialize without capabilities or rootUri/workspaceFolders. Concretely, structcodec.go:113-121 computes requiredMask &^ seen; any unlisted required field produces errMissing. It also fires when a hand-rolled JSON-RPC client or test fixture forgets a field the spec mandates.","commonSituations":"Custom editor integrations or test harnesses that build params by hand; clients targeting an older LSP spec revision where a field was optional; buggy proxies that strip fields; unit tests with hand-written JSON that drifted from the generated struct tags after a protocol regeneration.","solutions":["Diff the sent params against the LSP spec for that method and add every field named in the error message (the error lists exactly which properties are missing).","If the sender is your own code, serialize from the corresponding lsproto struct (e.g. *lsproto.DidOpenTextDocumentParams) instead of hand-writing JSON, so required fields cannot be dropped.","If you control the receiving side and the field is genuinely optional in your dialect, regenerate/adjust the struct tags in _generate/generate.mts so the field is not required, then rerun the generator.","For test fixtures, round-trip them through json.Marshal of the lsproto params type to validate they are complete."],"exampleFix":"// before (client sends incomplete params)\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"textDocument/didOpen\",\"params\":{\"textDocument\":{\"uri\":\"file:///a.ts\",\"languageId\":\"typescript\"}}}\n// after: include required `version` and `text`\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"textDocument/didOpen\",\"params\":{\"textDocument\":{\"uri\":\"file:///a.ts\",\"languageId\":\"typescript\",\"version\":1,\"text\":\"const x = 1;\"}}}","handlingStrategy":"validation","validationCode":"// client-side: assert params contain every required field before sending\nfunc checkRequired(obj map[string]any, required ...string) error {\n    var missing []string\n    for _, k := range required {\n        if _, ok := obj[k]; !ok {\n            missing = append(missing, k)\n        }\n    }\n    if len(missing) > 0 {\n        return fmt.Errorf(\"missing required properties: %s\", strings.Join(missing, \", \"))\n    }\n    return nil\n}\n\nerr := checkRequired(renameParams, \"textDocument\", \"position\", \"newName\")","typeGuard":"func hasAllRequired(params map[string]any, required []string) bool {\n    for _, k := range required {\n        if _, ok := params[k]; !ok {\n            return false\n        }\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["Build request params by marshaling the generated lsproto structs instead of hand-writing JSON maps.","Validate fixtures by unmarshaling them into the target lsproto params type in unit tests.","Keep the LSP meta model version in sync between client templates and the generated server code."],"tags":["lsp","json","validation","protocol"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}