sveltejs/kit · error · SvelteKitError

Could not deserialize binary form: data too short

Error message

Could not deserialize binary form: data too short

What it means

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.

Source

Thrown at packages/kit/src/runtime/form-utils.js:261

	}

	const header = await get_buffer(0, HEADER_BYTES);
	if (!header) throw deserialize_error('too short');

	if (header[0] !== BINARY_FORM_VERSION) {
		throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);
	}
	const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);
	const data_length = header_view.getUint32(1, true);
	const file_offsets_length = header_view.getUint16(5, true);

	// Validation uses embedded binary header fields (data_length, file_offsets_length)
	// rather than Content-Length, which proxies/middleboxes may strip or corrupt.
	// See: https://github.com/sveltejs/kit/issues/15299

	// Read the form data
	const data_buffer = await get_buffer(HEADER_BYTES, data_length);
	if (!data_buffer) throw deserialize_error('data too short');

	/** @type {Array<number | undefined>} */
	let file_offsets;
	/** @type {number} */
	let files_start_offset;
	if (file_offsets_length > 0) {
		// Read the file offset table
		const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
		if (!file_offsets_buffer) throw deserialize_error('file offset table too short');

		const parsed_offsets = JSON.parse(text_decoder.decode(file_offsets_buffer));

		if (
			!Array.isArray(parsed_offsets) ||
			parsed_offsets.some((n) => typeof n !== 'number' || !Number.isInteger(n) || n < 0)
		) {
			throw deserialize_error('invalid file offset table');
		}

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Ensure the request body is not truncated in transit (check proxy/body-size settings)
  2. Verify the client and server use the same SvelteKit serialization version
  3. Resubmit the form so a complete, consistent payload is sent
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/kit/src/runtime/form-utils.js:261 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/4f6ccf1d4f52b146. Report an issue: GitHub.