Skip to content

fix: preserve diagnostics for large command output - #141353

Merged
shakkernerd merged 1 commit into
mainfrom
fix-command-output
Sep 7, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
fix-command-output

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Formatting large command output can throw RangeError: Maximum call stack size exceeded, hiding the original output-limit error. The existing worktree Git integration test reproduces this on current main after its normal CI file ordering with a real 17 MiB Git blob.

Why This Change Was Made

Split normalized output into lines before sanitizing the retained 12-line tail. This removes the failing whole-output replacement while preserving carriage-return redraw handling, terminal safety, character limits, surrogate-safe slicing, and omission markers.

User Impact

Commands that exceed their output limit report the intended bounded diagnostic instead of failing inside error formatting.

Evidence

  • Reproduced the unchanged integration assertion on main d234f9d4d09273615508d34bb1b098e803630165; captured the original stack in formatCommandOutput.
  • The repaired content passed the same 136-file group and original opening order on Blacksmith Testbox: 2,769 tests passed, three skipped. The formerly failing Git case passed.
  • All 87 existing command formatter and Git diagnostic tests passed, including real oversized Git blobs, control characters, carriage returns, output budgets, and surrogate boundaries.
  • Changed-file formatting, lint, syntax, and diff checks passed. Independent source review and autoreview found no actionable issues.
  • Hosted CI passed, including the formerly failing shard and the aggregate gate. Exact-head ClawSweeper review returned Platinum with no findings.
  • Exact-head Testbox production and core-test typing passed. Its aggregate check later stopped before the coercion guard because the runner lacked corepack; equivalent hosted checks cover the remaining applicable gates. The unchanged plugin-media and runtime-sidecar inputs were excluded from unrelated global checks.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 7, 2026
@shakkernerd shakkernerd self-assigned this Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 12:38 PM ET / 16:38 UTC.

ClawSweeper review

What this changes

The PR sanitizes only the retained diagnostic lines so large command output can report its original failure without crashing during formatting.

Merge readiness

✅ Ready for maintainer review

The fix remains useful: current main and v2026.9.2 retain the failing whole-output replacement. The narrow patch preserves the existing diagnostic contract, and no actionable introduced defect was found.

Priority: P2
Reviewed head: 477b557fbb407650e97091f0cd68debaae29a558

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with preserved contracts, relevant existing coverage, and reported before/after integration validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate and changes no authority boundary; its body reports the real Git-blob formatter failure and successful ordered Testbox rerun.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate and changes no authority boundary; its body reports the real Git-blob formatter failure and successful ordered Testbox rerun.
Evidence reviewed 7 items Verified introduced change: The pinned merge-base-to-head diff changes only the formatter's sanitization order and equivalent omission detection. ANSI stripping, carriage-return normalization, character limits, and surrogate-safe slicing remain intact.
Current main still needs the repair: Fetched main still sanitizes the entire normalized output with a replacement callback before selecting the diagnostic tail.
Latest release comparison: The supplied latest release, v2026.9.2, also contains the whole-output replacement; this repair is not present in that release.
Findings None None.
Security None None.

How this fits together

OpenClaw's command-error formatter turns captured process output and termination metadata into bounded diagnostics. Git operations, worktree setup, and other command callers use those diagnostics in errors and logs.

flowchart TD
  A[Command output and exit status] --> B[Normalize terminal escapes and redraws]
  B --> C[Select last 12 lines]
  C --> D[Sanitize displayed lines]
  D --> E[Apply character budget and omission marker]
  E --> F[Command errors and logs]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0. Total 0 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 4 4 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 4 4 0

Review metrics

None.

Technical review

Best possible solution:

Keep diagnostic formatting in the shared owner, sanitizing retained lines while preserving existing termination details and output budgets.

Do we have a high-confidence way to reproduce the issue?

A concrete reproduction path exists in the real 17 MiB Git-blob test, and the author reports failure under the original CI ordering. That order-dependent failure was not independently rerun during this read-only review.

Is this the best way to solve the issue?

Yes. Selecting the retained lines before sanitization removes the reported failing operation without adding a competing formatter or changing command execution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against fe2f796e95e8.

Labels

Label changes:

  • add P2: This repairs a bounded error-reporting failure when command output exceeds its capture limit.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate and changes no authority boundary; its body reports the real Git-blob formatter failure and successful ordered Testbox rerun.

Label justifications:

  • P2: This repairs a bounded error-reporting failure when command output exceeds its capture limit.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate and changes no authority boundary; its body reports the real Git-blob formatter failure and successful ordered Testbox rerun.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff changes only the formatter's sanitization order and equivalent omission detection. ANSI stripping, carriage-return normalization, character limits, and surrogate-safe slicing remain intact. (src/process/command-error.ts:10, 477b557fbb40)
  • Current main still needs the repair: Fetched main still sanitizes the entire normalized output with a replacement callback before selecting the diagnostic tail. (src/process/command-error.ts:14, fe2f796e95e8)
  • Latest release comparison: The supplied latest release, v2026.9.2, also contains the whole-output replacement; this repair is not present in that release. (src/process/command-error.ts:14, 3928bad9badf)
  • Existing real-process regression boundary: The existing Git test creates a real 17 MiB blob and checks that text, raw, and buffered reads reject with an output-limit diagnostic. Production Git errors delegate to the changed formatter. (src/infra/git-exec.test.ts:247, 477b557fbb40)
  • Terminal-safety contract: The sanitizer accepts one string, strips ANSI sequences, and removes or visibly escapes control characters without introducing logical newlines. Mapping it over the retained lines preserves displayed-text sanitization, including empty lines. (packages/terminal-core/src/safe-text.ts:12, 477b557fbb40)
  • Captured validation report: The complete supplied PR body reports a main-branch failure with the real Git blob, followed by a passing 136-file Testbox group in the original order and 87 passing formatter/Git diagnostic tests. These are contributor-reported results, not executions performed in this review. Captured context sourceRevision: bb7dc2b871967a545e126243ffbd75099b43f4ad443c86eee8f5076e30118d32. (477b557fbb40)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@shakkernerd
shakkernerd merged commit e89fd82 into main Sep 7, 2026
189 checks passed
@shakkernerd
shakkernerd deleted the fix-command-output branch September 7, 2026 16:59
@shakkernerd

Copy link
Copy Markdown
Member Author

Fixed: large command output preserves its intended bounded diagnostic instead of crashing during error formatting.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
Preserve bounded, terminal-safe command diagnostics when captured output exceeds its limit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant