{"record":{"id":"2ad6b672877c57ae","repo":"deepseek-ai/deepseek-harness","slug":"lsp-message-body-was-not-valid-json-error-insta","errorCode":null,"errorMessage":"LSP message body was not valid JSON: ${error instanceof Error ? error.message : String(error)}","messagePattern":"LSP message body was not valid JSON: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lsp/lsp-stdio/src/framing.ts","lineNumber":84,"sourceCode":"    }\n    if (separator > MAX_HEADER_BYTES) {\n      throw new Error(`LSP header exceeded ${MAX_HEADER_BYTES} bytes`)\n    }\n    const headerText = this.buffer.toString('ascii', 0, separator)\n    const contentLength = parseContentLength(headerText)\n    if (contentLength > this.maxMessageBytes) {\n      throw new Error(`LSP message length ${contentLength} exceeds the ${this.maxMessageBytes}-byte limit`)\n    }\n    const bodyStart = separator + HEADER_SEPARATOR.length\n    const bodyEnd = bodyStart + contentLength\n    if (this.buffer.length < bodyEnd) return { ready: false }\n    const body = this.buffer.toString('utf8', bodyStart, bodyEnd)\n    this.buffer = this.buffer.subarray(bodyEnd)\n    try {\n      return { ready: true, message: JSON.parse(body) }\n    } catch (error) {\n      /* v8 ignore next -- JSON.parse throws a SyntaxError (an Error); the String() fallback is defensive. */\n      throw new Error(`LSP message body was not valid JSON: ${error instanceof Error ? error.message : String(error)}`)\n    }\n  }\n}\n\n/** Read the `Content-Length` header value (case-insensitive), rejecting a missing or non-numeric one. */\nfunction parseContentLength(headerText: string): number {\n  for (const line of headerText.split('\\r\\n')) {\n    const colon = line.indexOf(':')\n    if (colon < 0) continue\n    if (line.slice(0, colon).trim().toLowerCase() !== 'content-length') continue\n    const value = Number(line.slice(colon + 1).trim())\n    if (!Number.isInteger(value) || value < 0) {\n      throw new Error(`invalid Content-Length header: ${JSON.stringify(line)}`)\n    }\n    return value\n  }\n  throw new Error(`LSP header block missing Content-Length: ${JSON.stringify(headerText)}`)\n}","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/lsp/lsp-stdio/src/framing.ts#L66-L102","documentation":"Error \"LSP message body was not valid JSON: ${error instanceof Error ? error.message : String(error)}\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/lsp/lsp-stdio/src/framing.ts:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the LSP server to emit valid JSON message bodies."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}