fix(code-runtime-python): drop the now-dead per-line parse cap check

The unframed-buffer counter guard runs before every join and guarantees each
line is within FRAME_PARSE_CAP_BYTES, so the line-loop cap check was dead code
(its continue branch could never fire, failing the per-file 100% coverage gate
on index.ts). Removed with a comment explaining the invariant.
This commit is contained in:
Chinesezjc
2026-08-31 14:53:33 +08:00
committed by Tianyi Cui
parent 219d216c54
commit abf81a0905
@@ -1369,11 +1369,10 @@ export class PythonCodeRuntime extends CodeRuntime {
buffered = buffered.subarray(newline + 1)
/* v8 ignore next -- an empty line comes only from a forged `\n\n` write. */
if (line.length === 0) continue
// Drop an oversized frame BEFORE toString/JSON.parse: the 256 MiB
// wire ceiling bounds the raw bytes, not the decoded structure (see
// FRAME_PARSE_CAP_BYTES), so a near-ceiling compact wide frame must
// not be parsed whole.
if (line.length > FRAME_PARSE_CAP_BYTES) continue
// No per-line cap check here: the unframed-buffer counter above
// already guarantees every line is within FRAME_PARSE_CAP_BYTES
// before this join runs, so a cap check on the line would be
// dead code.
const text = line.toString('utf8')
// JSON.parse would silently ROUND an integer token outside the
// safe range before validation could see it, so a forged frame