Skip to content

Skip multipart parts with empty Content-Type instead of raising - #3

Open
magicmark wants to merge 3 commits into
masterfrom
fix-empty-content-type-heartbeat
Open

Skip multipart parts with empty Content-Type instead of raising#3
magicmark wants to merge 3 commits into
masterfrom
fix-empty-content-type-heartbeat

Conversation

@magicmark

@magicmark magicmark commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Multipart HTTP streams may contain empty parts (no headers, no body):

NO header fields are actually required in body parts. A body part that starts with a blank line, therefore, is allowed
~ https://www.rfc-editor.org/info/rfc2046/#section-5.1

(In our case, we see this (I think) due to being passed through multiple proxies which unpack and pack parts back together)

Anyway our current handling is too strict — it required every part to have Content-Type: application/json instead of just skipping empty ones.

Before

When this happens, applications see traceback like this:

gql.transport.exceptions.TransportProtocolError: Unexpected part content-type: . Expected 'application/json'.
Unexpected part content-type: . Expected 'application/json'.

After

✨ empty parts are ignored; no errors

@magicmark
magicmark force-pushed the fix-empty-content-type-heartbeat branch from 51d74b1 to 01926fa Compare June 30, 2026 05:45
@magicmark
magicmark changed the base branch from add_http_multipart_transport to master June 30, 2026 05:45
@magicmark
magicmark force-pushed the fix-empty-content-type-heartbeat branch 3 times, most recently from 1ff86bc to d0d2600 Compare June 30, 2026 06:02
magicmark and others added 2 commits June 30, 2026 15:02
Some GraphQL servers send multipart parts without a Content-Type
header as heartbeats or keep-alive padding. Previously this raised
a TransportProtocolError, crashing the subscription stream.

Co-Authored-By: Claude <noreply@anthropic.com>
@magicmark
magicmark force-pushed the fix-empty-content-type-heartbeat branch from 2b12b85 to 058f95c Compare June 30, 2026 20:02
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