Skip to content

fix(fetch): reject Request body for GET and HEAD methods - #5201

Merged
jedel1043 merged 5 commits into
boa-dev:mainfrom
HiteshShonak:fix/request-get-head-body
Aug 30, 2026
Merged

jedel1043 merged 5 commits into
boa-dev:mainfrom
HiteshShonak:fix/request-get-head-body

Conversation

@HiteshShonak

Copy link
Copy Markdown
Contributor

This Pull Request fixes/closes #5200.

It changes the following:

  • into_request_builder now checks if the method is GET or HEAD and throws a TypeError if a body is provided, matching the Fetch Standard.
  • Added regression tests for both GET and HEAD cases.

Testing:

cargo test -p boa_runtime request -- --nocapture

Spec reference: https://fetch.spec.whatwg.org/#dom-request

@HiteshShonak
HiteshShonak requested a review from a team as a code owner March 21, 2026 03:11
Copilot AI review requested due to automatic review settings March 21, 2026 03:11
@github-actions github-actions Bot added Waiting On Review Waiting on reviews from the maintainers C-Tests Issues and PRs related to the tests. C-Runtime Issues and PRs related to Boa's runtime features and removed Waiting On Review Waiting on reviews from the maintainers labels Mar 21, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Mar 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns Boa’s Request constructor with the Fetch Standard by rejecting request bodies for GET and HEAD methods, addressing issue #5200.

Changes:

  • Add a GET/HEAD + body validation in RequestInit::into_request_builder, returning a TypeError when violated.
  • Add regression tests asserting new Request(..., { method: "GET"/"HEAD", body: "x" }) throws a TypeError.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
core/runtime/src/fetch/request.rs Adds GET/HEAD body rejection logic during request construction.
core/runtime/src/fetch/tests/request.rs Adds regression tests for GET/HEAD requests with an explicit body.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/runtime/src/fetch/request.rs Resolved
Comment thread core/runtime/src/fetch/tests/request.rs Resolved
@github-actions

github-actions Bot commented Mar 21, 2026 •

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,125 53,125 0
Passed 51,051 51,051 0
Ignored 1,482 1,482 0
Failed 592 592 0
Panics 0 0 0
Conformance 96.10% 96.10% 0.00%

Tested main commit: d6ac6c4cb7d1a064eca1363ed7df2b1ec4ed6c8e
Tested PR commit: 3273766fb52bf69ec529583d4150bba2e295f92b
Compare commits: d6ac6c4...3273766

@codecov

codecov Bot commented Mar 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.87%. Comparing base (6ddc2b4) to head (3273766).
⚠️ Report is 960 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5201       +/-   ##
===========================================
+ Coverage   47.24%   59.87%   +12.63%     
===========================================
  Files         476      566       +90     
  Lines       46892    62820    +15928     
===========================================
+ Hits        22154    37615    +15461     
- Misses      24738    25205      +467     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 21, 2026
Comment thread core/runtime/src/fetch/request.rs Resolved
Comment thread core/runtime/src/fetch/request.rs Resolved
Comment thread core/runtime/src/fetch/request.rs Resolved
@HiteshShonak
HiteshShonak requested a review from jedel1043 April 12, 2026 04:21
@HiteshShonak
HiteshShonak force-pushed the fix/request-get-head-body branch from b99eec4 to 3273766 Compare April 25, 2026 18:47

@jedel1043 jedel1043 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.

LGTM! Thank you for the contribution!

@jedel1043
jedel1043 added this pull request to the merge queue Aug 30, 2026
Merged via the queue into boa-dev:main with commit ea9c973 Aug 30, 2026
22 checks passed
@github-actions github-actions Bot removed the Waiting On Review Waiting on reviews from the maintainers label Aug 30, 2026
@jedel1043 jedel1043 modified the milestones: v0.23.0, v0.22 Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Runtime Issues and PRs related to Boa's runtime features C-Tests Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request constructor accepts body for GET and HEAD methods instead of throwing

3 participants