windmill-labs/windmill · error

Model listing exceeded ${maxBytes} bytes

Error message

Model listing exceeded ${maxBytes} bytes

What it means

Thrown by readJsonWithLimit while streaming a response body once cumulative bytes exceed maxBytes before the JSON is complete. It bounds how much an untrusted model-listing payload can push into the parser: the abort signal limits how long a provider takes, not how many bytes it sends, and without this cap the parser would absorb an unbounded body.

Source

Thrown at frontend/src/lib/components/copilot/boundedJson.ts:24

 * would otherwise parse and sort whatever it sends. An abort signal bounds how long that takes,
 * not how much arrives.
 *
 * A leaf module of its own so it is testable: `copilot/lib` reaches Monaco through its imports.
 */
export async function readJsonWithLimit(response: Response, maxBytes: number): Promise<unknown> {
	const reader = response.body?.getReader()
	if (!reader) {
		return response.json()
	}
	const chunks: Uint8Array[] = []
	let received = 0
	while (true) {
		const { done, value } = await reader.read()
		if (done) break
		received += value.byteLength
		if (received > maxBytes) {
			await reader.cancel()
			throw new Error(`Model listing exceeded ${maxBytes} bytes`)
		}
		chunks.push(value)
	}
	const body = new Uint8Array(received)
	let offset = 0
	for (const chunk of chunks) {
		body.set(chunk, offset)
		offset += chunk.byteLength
	}
	return JSON.parse(new TextDecoder().decode(body))
}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Increase the byte limit if the provider legitimately returns very large model listings
  2. Use the trusted server-side model list endpoint instead of a raw provider response
  3. Have the caller surface the error as a configuration problem for that provider
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at frontend/src/lib/components/copilot/boundedJson.ts:24 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/9a393bd580d9c286. Report an issue: GitHub.