You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "liuxiaocs7 (via GitHub)" <gi...@apache.org> on 2026/09/07 03:52:45 UTC

[I] fix(computer-use): enforce JSON line limits in UTF-8 bytes [maka]

liuxiaocs7 opened a new issue, #4952:
URL: https://github.com/apache/maka/issues/4952

   ## What happened
   
   `decodeJsonLines` compares the accumulated unparsed stdout tail with `maxBufferBytes` using JavaScript `string.length`:
   
   ```ts
   if (rest.length > handlers.maxBufferBytes) {
     handlers.onOverflow();
   }
   ```
   
   `string.length` counts UTF-16 code units, while `maxBufferBytes` is a UTF-8 byte budget derived from the executor's negotiated `limits.maxResponseBytes`. Consequently, an unterminated JSON line containing CJK or emoji can consume substantially more memory than the declared limit before the host terminates the executor. For example, four CJK characters have length 4 but occupy 12 UTF-8 bytes.
   
   Expected behavior: the accumulated tail should overflow as soon as its UTF-8 encoded size exceeds `maxBufferBytes`. ASCII behavior and the inclusive boundary should remain unchanged.
   
   ## How to reproduce
   
   From the repository root at commit `492ff80f0`:
   
   ```bash
   node --experimental-strip-types --input-type=module <<'NODE'
   import { decodeJsonLines } from './packages/computer-use/src/stdio-json-rpc.ts';
   
   const cap = 4 * 1024 * 1024;
   const text = 'δΈ­'.repeat(Math.floor(cap / 3) + 1);
   let overflow = false;
   
   decodeJsonLines('', text, {
     maxBufferBytes: cap,
     onOverflow: () => { overflow = true; },
     onMessage: () => {},
   });
   
   console.log({
     limit: cap,
     characters: text.length,
     utf8Bytes: Buffer.byteLength(text),
     overflow,
   });
   NODE
   ```
   
   Observed output:
   
   ```text
   {
     limit: 4194304,
     characters: 1398102,
     utf8Bytes: 4194306,
     overflow: false
   }
   ```
   
   The input exceeds the 4 MiB byte limit, but overflow is not reported. With CJK input the current check can allow roughly three times the intended byte budget before firing.
   
   ## Environment
   
   - Maka commit: `492ff80f0`
   - OS: macOS 15.7.3
   - Surface: Computer Use / stdio JSON-RPC transport
   - Node.js: v24.14.0
   
   ## Logs, screenshots, or additional context
   
   The affected comparison is in `packages/computer-use/src/stdio-json-rpc.ts`. The minimal fix is to measure the accumulated tail with `Buffer.byteLength(rest, 'utf8')` and add regression coverage for over-limit multibyte input, an exact-limit multibyte input, and unchanged ASCII behavior.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] fix(computer-use): enforce JSON line limits in UTF-8 bytes [maka]

Posted by "liuxiaocs7 (via GitHub)" <gi...@apache.org>.
liuxiaocs7 commented on issue #4952:
URL: https://github.com/apache/maka/issues/4952#issuecomment-5564780874

   take


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] fix(computer-use): enforce JSON line limits in UTF-8 bytes [maka]

Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks closed issue #4952: fix(computer-use): enforce JSON line limits in UTF-8 bytes
URL: https://github.com/apache/maka/issues/4952


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org