Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"A request body was provided when none was expected" with proxies that set transfer-encoding #3267

Open
dbkr opened this issue Dec 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dbkr
Copy link

dbkr commented Dec 18, 2024

Describe the bug

When running a PDS behind some proxies (in this instance, a Cloudflare tunnel) any POST without a body fails with, "A request body was provided when none was expected". This is because the proxy sets a "Transfer-Encoding: Chunked" header even when no body is sent.

Arguably this is a bug in the proxy, but the getBodyPresence distinguishes between "no body" and "empty body" when the only thing that actually matters to the validator function is whether a body is present and non-zero length or absent/empty. The validateInput reads the body anyway, so it might be more robust to wait until after it reads the body and then just asserts that the body is present and non-zero length if one is expected and vice-versa.

I may be able to make a PR for this if welcome.

To Reproduce

Steps to reproduce the behavior:

  1. Run a PDS instance behind a Cloudflare tunnel
  2. Log in with a client and make a request with no body, eg. request an email confirmation token.
  3. Observe that the request is rejected with the above error.

Expected behavior

The request succeeds as normal.

Details

  • Operating system: Ubuntu 24.04.1 LTS
  • Node version: 20.11.1 (official PDS docker image)

Additional context

A workaround to this particular failure is to disable chunked transfer encoding in the cloudflare tunnel options.

@dbkr dbkr added the bug Something isn't working label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant