Skip to content

Serialise Pathnames in forked child errors - #24294

Merged
MikeMcQuaid merged 1 commit into
mainfrom
pathname-child-error-json
Oct 18, 2026
Merged

MikeMcQuaid merged 1 commit into
mainfrom
pathname-child-error-json

Conversation

@dduugg

@dduugg dduugg commented Oct 18, 2026 •

Copy link
Copy Markdown
Member
  • Convert Pathnames to strings in the JSON::Coder block in Utils.report_forked_child_error.

Follow-up to #24292, which fixed the BuildError path of #24291. ErrorDuringExecution#cmd can also contain Pathnames (e.g. from Utils.safe_popen_read or system_command! with a Pathname executable), and those still raised JSON::GeneratorError: Pathname not allowed in JSON, hiding the real child error. Handling Pathname in the coder covers every error type and field in one place.

The new spec in test/utils/fork_spec.rb reproduces the failure: it raises JSON::GeneratorError without the utils/fork.rb change and passes with it.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Code (Claude Opus 5.5) reviewed #24292, found the remaining ErrorDuringExecution case by round-tripping errors through report_forked_child_error and rewrite_child_error, then wrote the spec (red/green verified) and the one-line fix. I reviewed the diff and ran brew lgtm --online locally.


Summary by CodeRabbit

  • Bug Fixes
    • Error reports from forked processes now preserve Pathname commands as strings while retaining the original error class.

- #24292 stringified `BuildError` fields but `ErrorDuringExecution`
  commands can also hold `Pathname`s, which still raised
  `JSON::GeneratorError` and hid the real child error.
- Convert `Pathname`s in the `JSON::Coder` block so every error type
  and field is covered.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e9d3d4b0-22e8-409c-adde-4f350d202153
📥 Commits

Reviewing files that changed from the base of the PR and between 3073d6a and 15cb1a1.

📒 Files selected for processing: 2
  • Library/Homebrew/test/utils/fork_spec.rb
  • Library/Homebrew/utils/fork.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The forked-child error report converts Pathname objects to strings during JSON encoding. A test checks that a rewritten ErrorDuringExecution retains its class and exposes its command as strings.

Changes: Forked-child error reporting

Layer / File(s) Summary
Pathname command serialisation
Library/Homebrew/utils/fork.rb, Library/Homebrew/test/utils/fork_spec.rb
report_forked_child_error converts Pathname objects to strings during JSON encoding. The test checks that the rewritten error has class ErrorDuringExecution and command ["/usr/bin/false", "arg"].

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 15cb1

The change reports Pathname commands as strings while preserving the reconstructed error class. No merge-blocking issue is established.

Security architecture risk: ⚪ Minimal · up to 15cb1

The change preserves the existing error-reporting channel and error reconstruction behavior while allowing Pathname values to be reported as strings. No material security risk was identified as introduced or worsened by this PR.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure change is confined to transporting previously unserializable Pathname values through the existing child-error channel. The inspected change adds no command execution, privilege transition, or external input endpoint.

Trust Boundaries and Controls

  • observed — The receiver's class-name resolution and exception reconstruction predate this PR. Pathname normalization changes nested values, not the exception-class discriminator or reconstruction authority; the existing receiver behavior is not an introduced security concern.

Resilience and Maintainability Implications

  • observed — Error-channel creation, descriptor transfer and closure, parent receipt, and child reaping are unchanged. The normalization does not introduce a new ownership transfer, retry, or recovery state.
Pre-merge checks: Passed 4
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: serialising Pathname values in forked child errors.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MikeMcQuaid
MikeMcQuaid enabled auto-merge October 18, 2026 11:51
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Oct 18, 2026
Merged via the queue into main with commit a20e9d4 Oct 18, 2026
85 of 86 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the pathname-child-error-json branch October 18, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants