Skip to content

Commit 6b51f3c

Browse files
committed
fix(gateway): size the filesystem body limit for JSON-escaped content
A 10 MiB string of control characters serializes to roughly 60 MiB, since JSON emits six bytes per character, so the previous 16 MiB ceiling still rejected a legal write before the service could apply its own limit.
1 parent cf8e3c0 commit 6b51f3c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • packages/agent-gateway/src/routes

packages/agent-gateway/src/routes/fs.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ import {
6060

6161
/**
6262
* Body cap for the fs action route. `WorkspaceFsService.write` accepts 10 MiB
63-
* of decoded content, which is ~13.4 MiB once base64-encoded and wrapped in
64-
* JSON — well past Fastify's 1 MiB default, which would reject a legal write
65-
* as a transport error before `FS_TOO_LARGE` could ever be returned. Scoped to
66-
* this route so the raise does not widen the request surface of every other
63+
* of decoded content. Two encodings expand it: base64 costs ~4/3, and a UTF-8
64+
* string of control characters costs 6 bytes per character once JSON-escaped,
65+
* so a legal 10 MiB write can serialize to ~60 MiB. Anything under that is
66+
* rejected as a transport error before `FS_TOO_LARGE` can be returned. Scoped
67+
* to this route so the raise does not widen the request surface of every other
6768
* endpoint.
6869
*/
69-
export const FS_ACTION_BODY_LIMIT_BYTES = 16 * 1024 * 1024;
70+
export const FS_ACTION_BODY_LIMIT_BYTES = 64 * 1024 * 1024;
7071

7172
interface FsRouteHost {
7273
post(

0 commit comments

Comments
 (0)