Repository navigation
[PR] fix: account for deeply nested media without recursive stack growth - #6048
Conversation
[bot] 🏷 Duplicate screen: not a duplicate. Independent search of open+closed issues/PRs found no overlapping work on recursive media-walk depth. Nearest hits are different mechanisms: #5627 was a Verdict: MERGEABLE — after a routine rebase to current master plus CI green. Clean, surgical external contribution that meets the quality bar; no refactoring needed. Verified on the rebased head (cherry-picked the single commit
Code quality (⑤b): naming is clear ( One non-blocking observation, same mechanism, one line for completeness: guard status for Note: the branch is 64 commits behind master — please rebase before merge so CI runs against the current base. --- 结构化八问 ---
收工判定:可合 —— 修复正确、回归测试有牙、typecheck 与定向回归全绿、diff 干净;建议 rebase 到当前 master 后交 CI 全量把关,人工合并。 |
…ei#6038) Reviewer-added complement to the media-bytes walk fix in this PR: the same unbounded-recursion mechanism lives in estimateRawBodyTokens and estimateRawBodyBreakdown (src/preflight.ts), which walk every string leaf of the parsed client body on the proxy main path (handle.ts rawInputTokens stamping) and the side-request guard. A 20,000-level body overflows their recursive walks with RangeError exactly as it did mediaBytesOfWireBody. Converted both to the same iterative explicit-stack traversal; key inheritance, the NON_TEXT_BODY_KEYS exclusion set, top-level bucketing and the total invariant are preserved byte-for-byte. Adds tests/raw-body-walk-depth.test.ts: 20,000-level object and array chains with media-shaped bottoms (fail with RangeError on the recursive versions), plus shallow plumbing pins for exclusion/inheritance/bucketing.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1142-master.25b1671 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Problem
Valid 20,000-level request JSON overflows the recursive media-byte walk.
Changes
Traverse pending JSON values iteratively, preserving all existing media-shape accounting.
Regression coverage
20,000 nested containers, non-media text, malformed JSON and mixed media-wire siblings.
Validation
Passed against exact fork commit
01e42ad79402ea62220e7ac60c2d54075da8c4efin an isolated GitHub Actions checkout: validation job. The targeted regression and related suites,npm run typecheck, andnpm run buildall passed on Node 22. This is targeted verification, not the full upstream CI matrix.Related work
Related #4119, #4382 and #4923 address repricing/maximum-string handling, not traversal depth.
Closes #6038.