Skip to content

Merge train 208: Response.json shares ctor init validation, --platform bun null-body-status (v0.5.1586) - #10400

Merged
proggeramlug merged 4 commits into
mainfrom
train208r
Sep 17, 2026
Merged

proggeramlug merged 4 commits into
mainfrom
train208r

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

This train lands #10368 as v0.5.1586, on ff19bd536a. Three source commits, each verified to preserve its patch-id and authorship. No train repairs were needed; the train adds only the version bump.

  • fix(fetch): Response.json shares ctor init validation; --platform bun accepts null-body-status bodies (#10360) #10368 (#10360) — Response.json(value, init) skipped the ResponseInit validation that new Response(body, init) applies. Both now share one check, in Node's order: status range (RangeError), then statusText (TypeError), then the body/null-body-status conflict. So Response.json({a: 1}, {status: 204}) throws Node's TypeError instead of returning a 204. The fix covers both perry-stdlib and perry-ext-fetch. Programs compiled with --platform bun follow Bun instead, where a body with a null-body status is accepted.

Why this was still open

It was set aside earlier on the belief that another lane already carried the fix. That was wrong: checking the PR's content against main shows 387 lines that are not on main. The fix is still needed.

Its red checks also read worse than they are. gap-suite (3), (4) and (5) are the three regressions #10387 fixed on main — this branch predates that, so those failures are stale and clear on rebase. build-and-freshness belongs to the Docs checks (gettext catalog) workflow, which feeds pr-gate zero times. What remains is the benchmark-evidence freshness step in lint, which every PR inherits.

Validation

Validated head 57670cf415. Five-package release build pinned and hash-verified, and re-verified after the gap run so nothing rebuilt underneath the fixtures.

  • Crate suites: codegen 1570, runtime 3984, stdlib 139, hir 433, transform 137, cli 1139 — all green except main's one known runtime failure. perry-ext-fetch was added to the suite set for this train, because the PR edits that crate's lib.rs: 15/15, with shipped_staticlib_does_not_define_stdlib_owned_fetch_symbols explicitly ok. That guard forbids the ext archive from defining stdlib-owned fetch symbols (ext archives link before stdlib), and it is the test that caught fix(ext-fetch): own the Headers surface this crate already half-implemented (#10310) #10319's breakage.
  • Integration: issue_10360_bun_platform_response_null_body — 2 passed. This compiles and runs real TypeScript under both platform modes, which is the acceptance bar for a --platform behavioural change; a crate suite cannot see it.
  • All nine preflight gates pass, including both raw-handle ratchet invocations, the holders gate, and the unrooted-local-shape check against main.
  • Gap: filters fetch, response, headers, blob, bun, body, request. A platform filter was dropped: it matches zero fixtures, and the driver's vacuous-filter assertion aborted rather than reporting a false rc=0.

Every red attributed

  • test_bun_plugin — the decisive case, since this PR adds 47 lines to bun_compat/platform.rs. A/B against main's own artifact set: identical on both arms (node=1, main=0, train=0), with distinct build stamps asserted per arm. Same for test_hono_bundle.
  • test_issue_617_inline_await_fetch_with_auth — this one first produced an asymmetric result (main refused to link, train ran), which would have read as a finding. It was neither. The shared libperry_ext_http.a bundles a different tokio compilation than the pinned stdlib archive, so perry's perry-ext-net: outbound TCP panics — LTO dead-strips tokio CONTEXT statics #507/test_gap_fetch_request_from_node_incoming_message SIGABRTs deterministically on pristine main, and is in no allowlist #7629 guard refuses that link — and the archive happened to be coherent with only one arm. Rebuilt coherently per arm (one cargo invocation including perry-ext-http, so tokio unifies), both arms compile, run, and emit byte-identical correct output; node itself fails with ReferenceError: fetchWithAuth is not defined. An oracle failure.
  • test_issue_340_axios_response_props — both arms refuse the link identically, same libperry_ext_axios.a tokio-coherence guard. Symmetric environmental failure of the pinned package set, not a code difference. (The distinction matters: 617's arms disagreed, so it needed a coherent rebuild; 340's agree.)
  • Three node-oracle failures, each verified by running node directly: test_issue_4826_array_headers and test_node_http_post_body time out under the pinned v26.5.1.
  • Three declared parity-skip fixtures — two fastify (background server) and test_issue_9330_9517_mysql2_bundled (live MySQL). The harness skips them before compiling.

Note that --filter is a substring match over all fixtures, so these runs select test_issue_*/test_bun_* names that CI's gap suite (--filter test_gap_) never runs. Every test_gap_* fixture in scope passed.

Before merging, the pushed head and unchanged main are checked again. After merging, the rewritten commits are checked for preserved authorship and the main tree must match the validated train exactly.

Summary by CodeRabbit

  • Bug Fixes

    • Standardized Response and Response.json validation across Node-compatible runtimes.
    • Invalid status codes, status text, and bodies paired with null-body statuses now throw the appropriate errors.
    • Bun platform mode now accepts response bodies with statuses 204, 205, and 304, matching Bun behavior.
  • Documentation

    • Documented the response behavior differences between Node and Bun platform modes.
  • Tests

    • Added coverage for Node and Bun response handling, including dependency initialization.
  • Chores

    • Bumped the package version to 0.5.1586.

@proggeramlug
proggeramlug merged commit fe0cc15 into main Sep 17, 2026
18 of 20 checks passed
@proggeramlug
proggeramlug deleted the train208r branch September 17, 2026 04:16
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 614acb9a-d62d-4449-b46d-02bba389ea70

📥 Commits

Reviewing files that changed from the base of the PR and between ff19bd5 and 57670cf.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • CLAUDE.md
  • Cargo.toml
  • changelog.d/10368-response-null-body-status.md
  • crates/perry-codegen/src/codegen/entry/tests.rs
  • crates/perry-codegen/src/lower_call/native/native_runtime_branch.rs
  • crates/perry-codegen/src/runtime_decls/objects.rs
  • crates/perry-ext-fetch/src/lib.rs
  • crates/perry-ext-fetch/src/validation.rs
  • crates/perry-runtime/src/bun_compat/mod.rs
  • crates/perry-runtime/src/bun_compat/platform.rs
  • crates/perry-stdlib/src/fetch/body_clone.rs
  • crates/perry-stdlib/src/fetch/response_ctor.rs
  • crates/perry/src/commands/compile/collect_modules.rs
  • crates/perry/tests/issue_10360_bun_platform_response_null_body.rs
  • docs/src/cli/flags.md
  • test-files/test_gap_response_null_body_status_10360.ts

📝 Walkthrough

Walkthrough

The change adds shared Response initialization validation and Bun-specific handling for bodies with null-body statuses. Bun mode now sets a runtime flag before module code runs. Codegen, runtime, integration, and regression tests cover the behavior.

Changes

Response validation and Bun platform handling

Layer / File(s) Summary
Bun platform flag wiring
crates/perry-runtime/src/bun_compat/*, crates/perry-codegen/src/*, crates/perry/src/commands/compile/collect_modules.rs
Bun mode initializes a runtime flag before module top-level code executes. Codegen lowers setBunPlatform to js_set_bun_platform.
Shared Response validation
crates/perry-stdlib/src/fetch/*, crates/perry-ext-fetch/src/*
new Response and Response.json share status, statusText, and body/null-body status validation. Bun mode accepts bodies for statuses 204, 205, and 304.
Regression coverage and release records
crates/perry/tests/*, test-files/*, docs/src/cli/flags.md, changelog.d/*, Cargo.toml, CLAUDE.md
Tests cover Node and Bun behavior. Documentation, changelog, and version records describe the update.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Compiler
  participant RuntimeFlag
  participant ResponseValidation
  Compiler->>RuntimeFlag: initialize Bun mode before module code
  ResponseValidation->>RuntimeFlag: query Bun platform state
  RuntimeFlag-->>ResponseValidation: return enabled or disabled
  ResponseValidation-->>Compiler: apply platform-specific Response validation
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch train208r

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

1 participant