{"record":{"id":"4686973fdc5ea76f","repo":"biomejs/biome","slug":"invalid-value-for-content-type-expected-applicat","errorCode":null,"errorMessage":"invalid value for Content-Type expected \\\"application/vscode-jsonrpc\\\", got {value:?}","messagePattern":"invalid value for Content-Type expected \\\\\"application/vscode-jsonrpc\\\\\", got (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/biome_cli/src/service/mod.rs","lineNumber":475,"sourceCode":"\n    fn from_str(line: &str) -> Result<Self, Self::Err> {\n        let colon = line\n            .find(':')\n            .with_context(|| format!(\"could not find colon token in {line:?}\"))?;\n\n        let (name, value) = line.split_at(colon);\n        let value = value[1..].trim();\n\n        match name {\n            \"Content-Length\" => {\n                let value = value.parse().with_context(|| {\n                    format!(\"could not parse Content-Length header value {value:?}\")\n                })?;\n\n                Ok(Self::ContentLength(value))\n            }\n            \"Content-Type\" => {\n                ensure!(\n                    value.starts_with(\"application/vscode-jsonrpc\"),\n                    \"invalid value for Content-Type expected \\\"application/vscode-jsonrpc\\\", got {value:?}\"\n                );\n\n                Ok(Self::ContentType)\n            }\n            _ => Ok(Self::Unknown(name.into())),\n        }\n    }\n}\n","sourceCodeStart":457,"sourceCodeEnd":486,"githubUrl":"https://github.com/biomejs/biome/blob/45a19bbf1747401274f1be1f9f89d6af91367190/crates/biome_cli/src/service/mod.rs#L457-L486","documentation":"Header validation while reading LSP messages over the CLI service transport (crates/biome_cli/src/service/mod.rs:476). Each header line is split at the first colon; when the name is exactly 'Content-Type', the value must start with 'application/vscode-jsonrpc' (a charset suffix such as '; charset=utf-8' is accepted via starts_with). Any other value fails the ensure! and aborts the connection with this message. A missing Content-Type header is fine - only Content-Length is mandatory in LSP framing.","triggerScenarios":"Speaking the LSP wire protocol to a Biome server (e.g. biome __run-server or the daemon socket) and sending a header line 'Content-Type: <value>' where value does not start with application/vscode-jsonrpc - for example 'application/json' or 'text/plain'. Triggered by custom clients, hand-written socket scripts, or proxies that rewrite the header.","commonSituations":"Custom editor integrations and test harnesses that reuse a generic JSON-RPC framing implementation with Content-Type: application/json; HTTP proxies or middleware injecting a default Content-Type; curl-based experiments against the socket using the wrong header.","solutions":["Send the standard LSP value: Content-Type: application/vscode-jsonrpc; charset=utf-8 (the starts_with check accepts the charset suffix)","Or omit the Content-Type header entirely - the parser tolerates missing/unknown headers and only requires a valid Content-Length","If a proxy rewrites the header, bypass it for the Biome connection or configure it to preserve the original value"],"exampleFix":"# before (raw frame sent to the Biome server socket)\r\nContent-Type: application/json\r\n\r\n{...}\n\n# after\r\nContent-Type: application/vscode-jsonrpc; charset=utf-8\r\n\r\n{...}","handlingStrategy":"validation","validationCode":"// TypeScript - build LSP frames with the accepted Content-Type (or none at all)\nfunction writeMessage(socket: net.Socket, body: string): void {\n  const headers =\n    `Content-Length: ${Buffer.byteLength(body)}\\r\\n` +\n    `Content-Type: application/vscode-jsonrpc; charset=utf-8\\r\\n\\r\\n`;\n  socket.write(headers + body);\n}","typeGuard":"const isVscodeJsonrpcContentType = (value: string): boolean =>\n  value.trim().startsWith('application/vscode-jsonrpc');","tryCatchPattern":null,"preventionTips":["Reuse an established LSP client library (vscode-jsonrpc, lspower) instead of hand-rolling framing","If you must hand-roll, remember only Content-Length is mandatory - send no Content-Type rather than a wrong one","Validate header values against the LSP spec in your client's tests before talking to Biome"],"tags":["lsp","json-rpc","protocol","header-validation"],"backgroundTag":"lsp-header-validation","analyzedSha":"45a19bbf1747401274f1be1f9f89d6af91367190","analyzedAt":"2026-08-20T00:25:09.682Z","contentChangedAt":"2026-08-20T00:25:09.682Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}