Skip to content

fix: revive dead FormData Content-Type warning (#6067)#6070

Merged
harrishancock merged 3 commits intomainfrom
harris/2026-02-13-fix-form-data-warning
Feb 13, 2026
Merged

fix: revive dead FormData Content-Type warning (#6067)#6070
harrishancock merged 3 commits intomainfrom
harris/2026-02-13-fix-form-data-warning

Conversation

@harrishancock
Copy link
Collaborator

@harrishancock harrishancock commented Feb 13, 2026

The logWarning() in Body::Body that warns when a FormData body is paired with a custom Content-Type header was dead code. The comparison used ConstMimeType::operator==(kj::StringPtr), which compared the full substring after '/' against the subtype — so 'form-data; boundary=...' never matched 'form-data'.

Fix the comparison by parsing the content-type string into a MimeType first, then comparing against MimeType::FORM_DATA. The MimeType equality operator correctly ignores MIME parameters like boundary.

Also remove ConstMimeType::operator==(kj::StringPtr) entirely — it was a footgun with only this one (buggy) caller, and any future use would hit the same parameter-ignoring trap.

Add a streaming tail worker test that verifies the warning is emitted and captured in the tracing system when a Request is constructed with a FormData body and a custom Content-Type header.

Fixes #6067

@harrishancock harrishancock requested review from a team as code owners February 13, 2026 14:43
@codspeed-hq

This comment was marked as outdated.

harrishancock and others added 3 commits February 13, 2026 16:01
The logWarning() in Body::Body that warns when a FormData body is paired
with a custom Content-Type header was dead code. The comparison used
ConstMimeType::operator==(kj::StringPtr), which compared the full
substring after '/' against the subtype -- so 'form-data; boundary=...'
never matched 'form-data'.

Fix the comparison by parsing the content-type string into a MimeType
first, then comparing against MimeType::FORM_DATA. The MimeType equality
operator correctly ignores MIME parameters like boundary.

Also remove ConstMimeType::operator==(kj::StringPtr) entirely -- it was
a footgun with only this one (buggy) caller, and any future use would
hit the same parameter-ignoring trap.

Co-Authored-By: Claude <noreply@anthropic.com>
Several logWarning() call sites were guarded by isInspectorEnabled(),
which only returns true when the Chrome DevTools inspector is connected.
This meant warnings were silently dropped for streaming tail workers and
--verbose stderr logging.

Add IoContext::hasWarningHandler() that returns true if the inspector, a
streaming tail worker tracer, OR --verbose logging is active. Replace all
isInspectorEnabled() guards on warning paths with hasWarningHandler().

Co-Authored-By: Claude <noreply@anthropic.com>
Add a two-worker test that exercises several logWarning() code paths and
verifies the warnings are visible to a streaming tail worker:

  - FormData body with a custom Content-Type header (Body::Body)
  - Null-body status with zero-length body (Response constructor)

The "trigger" worker generates warnings in its fetch() handler, invoked
via a service binding from its test() entrypoint. The "tail" worker
collects streaming tail events and asserts that all expected warning
substrings appear within a polling timeout.

Co-Authored-By: Claude <noreply@anthropic.com>
@harrishancock harrishancock force-pushed the harris/2026-02-13-fix-form-data-warning branch from 783a335 to 56aeaf3 Compare February 13, 2026 16:26
@harrishancock harrishancock merged commit 6789c43 into main Feb 13, 2026
22 of 23 checks passed
@harrishancock harrishancock deleted the harris/2026-02-13-fix-form-data-warning branch February 13, 2026 17:08
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.

Custom content-type header with FormData body warning is dead code

2 participants