{"record":{"id":"4f6ccf1d4f52b146","repo":"sveltejs/kit","slug":"could-not-deserialize-binary-form-data-too-short","errorCode":null,"errorMessage":"Could not deserialize binary form: data too short","messagePattern":"Could not deserialize binary form: data too short","errorType":"exception","errorClass":"SvelteKitError","httpStatus":400,"severity":"error","filePath":"packages/kit/src/runtime/form-utils.js","lineNumber":261,"sourceCode":"\t}\n\n\tconst header = await get_buffer(0, HEADER_BYTES);\n\tif (!header) throw deserialize_error('too short');\n\n\tif (header[0] !== BINARY_FORM_VERSION) {\n\t\tthrow deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);\n\t}\n\tconst header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);\n\tconst data_length = header_view.getUint32(1, true);\n\tconst file_offsets_length = header_view.getUint16(5, true);\n\n\t// Validation uses embedded binary header fields (data_length, file_offsets_length)\n\t// rather than Content-Length, which proxies/middleboxes may strip or corrupt.\n\t// See: https://github.com/sveltejs/kit/issues/15299\n\n\t// Read the form data\n\tconst data_buffer = await get_buffer(HEADER_BYTES, data_length);\n\tif (!data_buffer) throw deserialize_error('data too short');\n\n\t/** @type {Array<number | undefined>} */\n\tlet file_offsets;\n\t/** @type {number} */\n\tlet files_start_offset;\n\tif (file_offsets_length > 0) {\n\t\t// Read the file offset table\n\t\tconst file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);\n\t\tif (!file_offsets_buffer) throw deserialize_error('file offset table too short');\n\n\t\tconst parsed_offsets = JSON.parse(text_decoder.decode(file_offsets_buffer));\n\n\t\tif (\n\t\t\t!Array.isArray(parsed_offsets) ||\n\t\t\tparsed_offsets.some((n) => typeof n !== 'number' || !Number.isInteger(n) || n < 0)\n\t\t) {\n\t\t\tthrow deserialize_error('invalid file offset table');\n\t\t}","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/form-utils.js#L243-L279","documentation":"Deserialization guard for binary form bodies: the header parsed successfully, but the embedded data_length indicates more payload than the stream actually delivered (buffered data shorter than declared). This validation deliberately uses the header's length fields rather than Content-Length, which proxies may rewrite.","triggerScenarios":"Thrown at packages/kit/src/runtime/form-utils.js:261 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the request body is not truncated in transit (check proxy/body-size settings)","Verify the client and server use the same SvelteKit serialization version","Resubmit the form so a complete, consistent payload is sent"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}