{"record":{"id":"1c1fa1a6f19520c9","repo":"microsoft/typescript-go","slug":"expected-s-value-s-got-s","errorCode":null,"errorMessage":"expected %s value %s, got %s","messagePattern":"expected (.+?) value (.+?), got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/lsp/lsproto/lsp.go","lineNumber":108,"sourceCode":"\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}\n}\n\nfunc assertAtMostOne(message string, count int) {\n\tif count > 1 {\n\t\tpanic(message)\n\t}\n}\n\n// jsonKeyCheck compares a raw JSON key token (including quotes) against a Go string.\nfunc jsonKeyCheck(name []byte, key string) bool {\n\treturn len(name) == len(key)+2 && name[0] == '\"' && string(name[1:len(name)-1]) == key\n}","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/lsp/lsproto/lsp.go#L90-L126","documentation":"Signals that a JSON literal-enum type in the LSP schema (values declared as fixed string literals, like MarkupKind, TextDocumentSyncKind, DiagnosticSeverity, or CodeActionKind literals) received a value that is not one of the enumerated literals. The generated decoder tries each allowed literal and, on exhaustion, calls errLiteralMismatch(typeName, expected, got) naming the type, the expected literal, and the offending bytes.","triggerScenarios":"Sending \"markupKind\": \"markdown\" instead of \"markdown\" vs \"plaintext\" exact-match; setting severity as a string when an integer literal is required; a completion trigger kind outside the enum; any typo or case mismatch in an enum-valued field (LSP enums are case-sensitive).","commonSituations":"Typos or casing errors (\"Markdown\" vs \"markdown\") from hand-built payloads; version skew where a newer client sends a literal the server's generated enum does not know yet; config-driven injection of enum values from user settings without validation.","solutions":["Compare the `got` bytes in the error with the `expected` literal and correct the value to the exact enumerated literal from the LSP spec.","Copy literal values from the corresponding lsproto constants (e.g. lsproto.MarkupKindMarkdown) rather than retyping strings.","If a genuinely new literal is being rejected, regenerate lsp_generated.go from the updated meta model.","Sanitize user-supplied enum strings at your config boundary before forwarding them into LSP messages."],"exampleFix":"// before\n{\"contents\":{\"kind\":\"Markdown\",\"value\":\"hi\"}}\n// after\n{\"contents\":{\"kind\":\"markdown\",\"value\":\"hi\"}}","handlingStrategy":"type-guard","validationCode":"// whitelist enum values before injecting user config into LSP messages\nvar markupKinds = map[string]bool{\"plaintext\": true, \"markdown\": true}\n\nif !markupKinds[userSetting] {\n    return fmt.Errorf(\"invalid markup kind %q\", userSetting)\n}","typeGuard":"func isValidEnum(v any, allowed map[string]bool) bool {\n    s, ok := v.(string)\n    return ok && allowed[s]\n}","tryCatchPattern":null,"preventionTips":["Use exact lowercase literals from the LSP spec; enums are case-sensitive.","Reference lsproto constants (e.g. lsproto.MarkupKindMarkdown) instead of retyping strings.","Validate user-supplied enum strings at the settings boundary."],"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"}