fix: bound miscellaneous unbounded file reads across 5 modules#110516
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 18, 2026, 6:15 PM ET / 22:15 UTC. Summary PR surface: Source +22, Tests +112, Docs +4. Total +138 across 10 files. Reproducibility: yes. source and the supplied terminal transcript give a concrete oversized-file path for each bounded-read caller, although this read-only review did not rerun the exact head locally. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Keep the descriptor-pinned and regular-file bounded-read split, retain the focused oversized-file tests and documentation, and land only after confirming that 8 MiB is the intended supported ceiling for both existing config-file flags. Do we have a high-confidence way to reproduce the issue? Yes, source and the supplied terminal transcript give a concrete oversized-file path for each bounded-read caller, although this read-only review did not rerun the exact head locally. Is this the best way to solve the issue? Unclear until the CLI compatibility choice is confirmed: the shared bounded-reader split is the maintainable implementation, but a fixed new limit for established file flags needs explicit acceptance. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 19d887169f78. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +22, Tests +112, Docs +4. Total +138 across 10 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (9 earlier review cycles; latest 8 shown)
|
7c1b61f to
8b2d3a8
Compare
|
Updated PR body with detailed evidence, compatibility assessment, and triage context. Branch has been rebased onto current main. @clawsweeper re-review |
|
Fixed the P1 helper-result misuse: all 5 files now correctly destructure { buffer } from readRegularFileSync/readRegularFile before calling .toString(). Branch rebased to current main. @clawsweeper re-review |
a2fda29 to
70b612f
Compare
|
Fixed TS6133 error: removed unused |
readRegularFile and readRegularFileSync return { buffer, stat },
not a string. All 4 new call sites passed the raw object to functions
expecting a string (JSON.parse, RegExp.test, template literals, etc.),
causing TS2345 type errors and runtime failures.
Fix each call by extracting .buffer and calling .toString('utf8')
before passing the result to string consumers.
|
Added real behavior proof with runtime transcript and test results to the PR body. This PR also supersedes PR #110555 for the cleanup.ts change. @clawsweeper re-review |
Real Runtime Behavior ProofThis comment provides the real runtime proof that ClawSweeper requested. It covers all 5 changed modules with actual execution evidence. Test Suite Results (31 tests passing)All 5 affected test files pass on the current branch head ( Runtime Behavior Proof (16 scenarios)Terminal transcript from exercising all 5 changed code paths with the actual What Was Tested
Key Assertions Proven
CI StatusAll CI checks are green:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: 陈宪彪0668000387 <[email protected]>
# Conflicts: # src/logging/diagnostic-support-export.ts # src/plugins/bundle-commands.ts
Co-authored-by: 陈宪彪0668000387 <[email protected]>
|
Merged via squash.
|
…law#110516) * fix: bound misc unbounded fs.readFile calls; remove unused fs import * fix: decode buffer to string before passing to string consumers readRegularFile and readRegularFileSync return { buffer, stat }, not a string. All 4 new call sites passed the raw object to functions expecting a string (JSON.parse, RegExp.test, template literals, etc.), causing TS2345 type errors and runtime failures. Fix each call by extracting .buffer and calling .toString('utf8') before passing the result to string consumers. * style: fix oxfmt formatting in config-set-input.ts * fix: bound config and trajectory metadata reads Co-authored-by: 陈宪彪0668000387 <[email protected]> * refactor: isolate bounded read ownership Co-authored-by: 陈宪彪0668000387 <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Five modules use unbounded fs.readFileSync/fs.promises.readFile calls on user-controlled file paths. A corrupted or oversized file at any of these paths can OOM the process:
Why This Change Was Made
PR #101472 established readRegularFileSync/readRegularFile with maxBytes as the standard bounded-read primitive. These five sites were the remaining unbounded read calls on user-controlled file paths.
User Impact
No user-visible change. Each file type has a generous cap (1-10 MB). Files exceeding the cap produce graceful error/fallback instead of crashing. All existing tests pass unchanged.
Evidence
Runtime Behavior Proof
Terminal transcript demonstrating the bounded reader behavior with normal and oversized files, using the actual
readRegularFileSyncfrom@openclaw/fs-safe/advanced:The bounded reader correctly:
Test Results
All existing and affected tests pass with the bounded read changes:
CI: all checks green — check-lint, check-prod-types, check-test-types, check-additional-extension-package-boundary, all 17 test shards, openclaw/ci-gate, all CodeQL security checks.
Changes by file
Each file replaces
fs.readFileSync(path, encoding)orfs.promises.readFile(path, encoding)with:Duplicate PR Resolution
PR #110555 has been closed. Its trajectory-pointer bounded-read change is consolidated into this PR, which covers 5 files and is the canonical landing candidate.
Provenance
Follows PR #101472 (merged) and PR #101477 patterns.