From abf81a09050d8d65e3b36d7012c3088cc53bf7c3 Mon Sep 17 00:00:00 2001 From: Chinesezjc Date: Tue, 25 Aug 2026 21:38:01 +0800 Subject: [PATCH] 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. --- packages/code-runtime/code-runtime-python/src/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/code-runtime/code-runtime-python/src/index.ts b/packages/code-runtime/code-runtime-python/src/index.ts index f17a0bc1e2..3068eef776 100644 --- a/packages/code-runtime/code-runtime-python/src/index.ts +++ b/packages/code-runtime/code-runtime-python/src/index.ts @@ -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