[PR #4870] [CLOSED] fix(setup): preserve large TOML documents without call stack limits (#4856) #6450

Closed
opened 2026-10-31 01:14:32 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4870
Author: @prasad2512
Created: 10/17/2026
Status: ❌ Closed

Base: main ← Head: fix/toml-call-stack-limit


📝 Commits (1)

  • b29add2 fix(setup): preserve large TOML documents without call stack limits (#4856)

📊 Changes

2 files changed (+59 additions, -3 deletions)

View changed files

➕ src/application/ClientConfigurationDocument.tomlCapacity.test.ts (+56 -0)
📝 src/application/ClientConfigurationDocument.ts (+3 -3)

📄 Description

Summary

Fixes #4856

When performing rea setup or rea uninstall against clients configured with TOML files (such as Codex config.toml or Grok Build config.toml), upsertTomlServerSection retains lines across table boundaries and multiline server replacements by spreading lines into kept.push(...pending), kept.push(...disabledLines), and kept.push(...replacement.split("\n")). When processing valid configuration documents with a large number of lines (>65,536 lines), spreading array arguments exceeds the V8 function argument threshold and throws RangeError: Maximum call stack size exceeded.

This change replaces array spread arguments with scalar iteration loops, allowing configuration documents of arbitrary size to be preserved and serialized safely.

Problem and expected behavior

On a valid TOML configuration document containing many retained lines (e.g. 70,000+ blank lines or comments), running serializeClientConfiguration(updated, "toml", original) or serializeClientConfiguration(updated, "grok", original) fails with:

RangeError: Maximum call stack size exceeded
    at upsertTomlServerSection (.../ClientConfigurationDocument.ts)

Expected behavior:
Valid TOML documents are processed and serialized without failing on call stack argument limits, preserving all existing comments, blank lines, and configuration entries.

Change and scope

Replaces the 3 occurrences of kept.push(...array) in upsertTomlServerSection with for (const line of array) kept.push(line);, consistent with other loops in the same function.

Follow the contribution scope.
Ordinary fix within existing configuration parsing boundary; maintainer scope decision: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/application/ClientConfigurationDocument.ts (upsertTomlServerSection)
  • Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing boundary)
  • CLI and MCP/tool-catalog contract: none
  • Provider, bridge, target-format, or platform compatibility: improves TOML client support (Codex, Grok Build)
  • Evidence, artifact, provenance, or reconstruction contract: none
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none
  • Generated metadata, package, or installation impact: none

Expected effects:

  • Change process memory, registers, files, or configuration.

Evidence and regression coverage

  • Tests added or updated: src/application/ClientConfigurationDocument.tomlCapacity.test.ts
  • Base reproduction or other evidence: Verified on 8a247fc70 that parseClientConfiguration followed by serializeClientConfiguration on a document with >65,536 lines throws RangeError: Maximum call stack size exceeded.
  • User-visible CLI/MCP output (if applicable): rea setup and rea uninstall complete successfully on large TOML documents.
  • Remaining proof gaps: none

Validation performed

  • npm run test:local -- src/application/ClientConfigurationDocument.tomlCapacity.test.ts — 2 tests passed (3.7s)
  • npm run test:local -- src/application/Setup.configuration.test.ts — 21 tests passed (84ms)
  • npm run check:fast — 2 tasks successful (typecheck + lint passed without errors)
  • npm run format:check — passed (all files use correct format)

Compatibility, safety, and release

  • Breaking changes or migration steps: none
  • Real Hopper/Ghidra, browser, or OS coverage: platform-independent
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none

Author readiness

Human owner: @prasad2512

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4870 **Author:** [@prasad2512](https://github.com/prasad2512) **Created:** 10/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/toml-call-stack-limit` --- ### 📝 Commits (1) - [`b29add2`](https://github.com/morluto/rea/commit/b29add21395ba79d07657fbbf5fe7694742740f9) fix(setup): preserve large TOML documents without call stack limits (#4856) ### 📊 Changes **2 files changed** (+59 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `src/application/ClientConfigurationDocument.tomlCapacity.test.ts` (+56 -0) 📝 `src/application/ClientConfigurationDocument.ts` (+3 -3) </details> ### 📄 Description ## Summary Fixes #4856 When performing `rea setup` or `rea uninstall` against clients configured with TOML files (such as Codex `config.toml` or Grok Build `config.toml`), `upsertTomlServerSection` retains lines across table boundaries and multiline server replacements by spreading lines into `kept.push(...pending)`, `kept.push(...disabledLines)`, and `kept.push(...replacement.split("\n"))`. When processing valid configuration documents with a large number of lines (>65,536 lines), spreading array arguments exceeds the V8 function argument threshold and throws `RangeError: Maximum call stack size exceeded`. This change replaces array spread arguments with scalar iteration loops, allowing configuration documents of arbitrary size to be preserved and serialized safely. ## Problem and expected behavior On a valid TOML configuration document containing many retained lines (e.g. 70,000+ blank lines or comments), running `serializeClientConfiguration(updated, "toml", original)` or `serializeClientConfiguration(updated, "grok", original)` fails with: ``` RangeError: Maximum call stack size exceeded at upsertTomlServerSection (.../ClientConfigurationDocument.ts) ``` Expected behavior: Valid TOML documents are processed and serialized without failing on call stack argument limits, preserving all existing comments, blank lines, and configuration entries. ## Change and scope Replaces the 3 occurrences of `kept.push(...array)` in `upsertTomlServerSection` with `for (const line of array) kept.push(line);`, consistent with other loops in the same function. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Ordinary fix within existing configuration parsing boundary; maintainer scope decision: not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/application/ClientConfigurationDocument.ts` (`upsertTomlServerSection`) - Contribution scope fit and linked maintainer decision: not applicable (bug fix within existing boundary) - CLI and MCP/tool-catalog contract: none - Provider, bridge, target-format, or platform compatibility: improves TOML client support (Codex, Grok Build) - Evidence, artifact, provenance, or reconstruction contract: none - Target selection, authority, upstream behavior, and cleanup details (if applicable): none - Generated metadata, package, or installation impact: none Expected effects: - [x] Change process memory, registers, files, or configuration. ## Evidence and regression coverage - Tests added or updated: `src/application/ClientConfigurationDocument.tomlCapacity.test.ts` - Base reproduction or other evidence: Verified on `8a247fc70` that `parseClientConfiguration` followed by `serializeClientConfiguration` on a document with >65,536 lines throws `RangeError: Maximum call stack size exceeded`. - User-visible CLI/MCP output (if applicable): `rea setup` and `rea uninstall` complete successfully on large TOML documents. - Remaining proof gaps: none ## Validation performed - `npm run test:local -- src/application/ClientConfigurationDocument.tomlCapacity.test.ts` — 2 tests passed (3.7s) - `npm run test:local -- src/application/Setup.configuration.test.ts` — 21 tests passed (84ms) - `npm run check:fast` — 2 tasks successful (typecheck + lint passed without errors) - `npm run format:check` — passed (all files use correct format) ## Compatibility, safety, and release - Breaking changes or migration steps: none - Real Hopper/Ghidra, browser, or OS coverage: platform-independent - Package or release metadata impact: none - Security, privacy, process, or containment review: none ## Author readiness Human owner: @prasad2512 - [ ] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [ ] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [ ] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:14:32 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6450
No description provided.