Skip to content

fix: Don't set redundant Content-Length on file upload requests#1730

Open
elierotenberg wants to merge 1 commit into
googleapis:mainfrom
elierotenberg:fix-files-upload-content-length
Open

fix: Don't set redundant Content-Length on file upload requests#1730
elierotenberg wants to merge 1 commit into
googleapis:mainfrom
elierotenberg:fix-files-upload-content-length

Conversation

@elierotenberg

Copy link
Copy Markdown

fetch derives Content-Length from the request body. Setting it explicitly sent a duplicate header, which undici >= 7.26 rejects with UND_ERR_INVALID_ARG when a userland dispatcher is active.

Fixes #1718

@elierotenberg

Copy link
Copy Markdown
Author

Note: I considered adding a test where we explicitly use an undici global dispatcher but this requires bumping undici and setting up a temporary http server (because spying on fetch would not use the global dispatcher) so I decided not to. I'm happy to do it if you wish though.

fetch derives Content-Length from the request body. Setting it
explicitly sent a duplicate header, which undici >= 7.26 rejects with
UND_ERR_INVALID_ARG when a userland dispatcher is active.

Fixes googleapis#1718
@elierotenberg elierotenberg force-pushed the fix-files-upload-content-length branch from 26c397c to bdc41ca Compare June 28, 2026 10:03
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.

files.upload sets a redundant Content-Length that breaks uploads under a userland undici dispatcher

1 participant