[whatwg/fetch] llow empty GET/HEAD bodies to be ignored with a warning instead of throwing (Issue #1909)

chichmohamedh-arch created an issue (whatwg/fetch#1909)

### What is the issue with the Fetch Standard?

GitHub Issue Draft: Allow empty GET/HEAD bodies

Title:
Proposal: Allow empty GET/HEAD bodies to be ignored with a warning instead of throwing

Description / Problem

Currently, the Fetch API throws a TypeError when a GET or HEAD request is constructed with a body, even if the body is empty:

fetch('/example', { method: 'GET', body: new FormData() }); // TypeError


This behavior is technically correct per the spec, but creates unnecessary friction for developers who generate forms programmatically or serialize requests. An empty body has no effect on the HTTP request semantics.

Current Behavior

fetch('/example', { method: 'GET', body: new FormData() }); 
// Throws: TypeError: Request with GET/HEAD method cannot have body


Proposed Behavior

fetch('/example', { method: 'GET', body: new FormData() }); 
// Proceeds normally
// Console warning: "Fetch warning: GET/HEAD request body ignored (empty)"


Non-empty bodies (FormData with entries, Blob/ArrayBuffer with length > 0) should continue to throw TypeError.

Empty bodies are ignored silently (with warning) — functionally identical to requests without a body.

Minimal Reproduction Example

<form id="myForm">
  <input name="foo" value="bar">
</form>

<script>
const form = document.getElementById('myForm');
const emptyFormData = new FormData(); // intentionally empty

fetch('/example', { method: 'GET', body: emptyFormData })
  .then(res => console.log('Success', res))
  .catch(err => console.error('Error', err));
</script>


Expected: request proceeds, warning appears in console.
Current: throws TypeError.

Motivation / Rationale

Developer experience

Empty bodies occur naturally when serializing forms or generating requests dynamically.

Preventing harmless requests creates friction.

Backward-compatible

Behavior for non-empty bodies remains unchanged.

Servers see no difference; empty body has no effect.

Consistency with other APIs

XHR, Python requests, Go http allow empty GET bodies silently.

Design principle

“Less should raise errors, extra should raise warnings” — safe, minimal-friction behavior.

References

Fetch spec: https://fetch.spec.whatwg.org/

RFC 7231: Section 4.3.1 GET, Section 4.3.2 HEAD

Observed friction: multiple Stack Overflow and GitHub issues

Suggested Implementation Notes (Optional)

Detect if body is empty (FormData with zero entries, Blob/ArrayBuffer of length 0)

If empty:

Ignore body

Emit console warning

If non-empty, retain current throwing behavior

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/1909
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/issues/1909@github.com>

Received on Friday, 6 February 2026 02:00:18 UTC