{"record":{"id":"9a393bd580d9c286","repo":"windmill-labs/windmill","slug":"model-listing-exceeded-maxbytes-bytes","errorCode":null,"errorMessage":"Model listing exceeded ${maxBytes} bytes","messagePattern":"Model listing exceeded (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/boundedJson.ts","lineNumber":24,"sourceCode":" * would otherwise parse and sort whatever it sends. An abort signal bounds how long that takes,\n * not how much arrives.\n *\n * A leaf module of its own so it is testable: `copilot/lib` reaches Monaco through its imports.\n */\nexport async function readJsonWithLimit(response: Response, maxBytes: number): Promise<unknown> {\n\tconst reader = response.body?.getReader()\n\tif (!reader) {\n\t\treturn response.json()\n\t}\n\tconst chunks: Uint8Array[] = []\n\tlet received = 0\n\twhile (true) {\n\t\tconst { done, value } = await reader.read()\n\t\tif (done) break\n\t\treceived += value.byteLength\n\t\tif (received > maxBytes) {\n\t\t\tawait reader.cancel()\n\t\t\tthrow new Error(`Model listing exceeded ${maxBytes} bytes`)\n\t\t}\n\t\tchunks.push(value)\n\t}\n\tconst body = new Uint8Array(received)\n\tlet offset = 0\n\tfor (const chunk of chunks) {\n\t\tbody.set(chunk, offset)\n\t\toffset += chunk.byteLength\n\t}\n\treturn JSON.parse(new TextDecoder().decode(body))\n}\n","sourceCodeStart":6,"sourceCodeEnd":36,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/boundedJson.ts#L6-L36","documentation":"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.","triggerScenarios":"Thrown at frontend/src/lib/components/copilot/boundedJson.ts:24 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase the byte limit if the provider legitimately returns very large model listings","Use the trusted server-side model list endpoint instead of a raw provider response","Have the caller surface the error as a configuration problem for that provider"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}