deepseek-ai/deepseek-harness · error · Error
invalid Content-Length header
Error message
invalid Content-Length header: ${JSON.stringify(line)} What it means
LSP stdio framing parse failure: the Content-Length header line is malformed (non-numeric or empty value), so the framed message cannot be sized. Raised by parseContentLength while parsing a header block off the byte stream; the stream is treated as a protocol violation.
Solutions
- Fix the LSP server to emit a valid Content-Length header line.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/lsp/lsp-stdio/src/framing.ts:97 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24).
Data as JSON: /api/errors/d63478f13d9a9cce.
Report an issue: GitHub.
Appendix: source
Thrown at packages/lsp/lsp-stdio/src/framing.ts:97
this.buffer = this.buffer.subarray(bodyEnd)
try {
return { ready: true, message: JSON.parse(body) }
} catch (error) {
/* v8 ignore next -- JSON.parse throws a SyntaxError (an Error); the String() fallback is defensive. */
throw new Error(`LSP message body was not valid JSON: ${error instanceof Error ? error.message : String(error)}`)
}
}
}
/** Read the `Content-Length` header value (case-insensitive), rejecting a missing or non-numeric one. */
function parseContentLength(headerText: string): number {
for (const line of headerText.split('\r\n')) {
const colon = line.indexOf(':')
if (colon < 0) continue
if (line.slice(0, colon).trim().toLowerCase() !== 'content-length') continue
const value = Number(line.slice(colon + 1).trim())
if (!Number.isInteger(value) || value < 0) {
throw new Error(`invalid Content-Length header: ${JSON.stringify(line)}`)
}
return value
}
throw new Error(`LSP header block missing Content-Length: ${JSON.stringify(headerText)}`)
}
View on GitHub (pinned to b150a551b8)