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

Sending wrong multipart headers results in a 500 error #3190

Open
kudresov opened this issue Feb 27, 2024 · 1 comment
Open

Sending wrong multipart headers results in a 500 error #3190

kudresov opened this issue Feb 27, 2024 · 1 comment
Labels

Comments

@kudresov
Copy link

kudresov commented Feb 27, 2024

Describe the bug

When making request to Yoga with invalid mutlipart headers an error bubbles up all the way to the top and results in a 500,

It looks like when calling multer it throws an error. Could the error be caught inside Yoga and GQL error (with a 200 status code) returned at this point rather than letting the error bubble up all the way?

Your Example Website or App

https://github.com/kudresov/yoga-validation-issue/tree/express

Steps to Reproduce the Bug or Issue

Replicating issue

  1. Start Server using npm start
  2. Make following curl request
curl --request POST -i --location --header 'Content-Type: multipart/form-data' --header 'Cookies: ' --header 'X-Escape-Request-ID: abb75fdd19af42e09047f57663eb6f87' --data '{"query": "mutation graphql { __typename }"}' http://localhost:4000/graphql

Result

You should see an error like this

Server is running on http://localhost:4000/graphql
ERR Error: Multipart: Boundary not found
    at new Multipart (/Users/vk/repo/yoga-issue/node_modules/busboy/lib/types/multipart.js:233:13)
    at getInstance (/Users/vk/repo/yoga-issue/node_modules/busboy/lib/index.js:33:12)
    at module.exports (/Users/vk/repo/yoga-issue/node_modules/busboy/lib/index.js:56:10)
    at /Users/vk/repo/yoga-issue/node_modules/@whatwg-node/node-fetch/cjs/Body.js:121:45
    at new Promise (<anonymous>)
    at Request.formData (/Users/vk/repo/yoga-issue/node_modules/@whatwg-node/node-fetch/cjs/Body.js:120:16)
    at parsePOSTMultipartRequest (file:///Users/vk/repo/yoga-issue/node_modules/graphql-yoga/esm/plugins/request-parser/post-multipart.js:10:37)
    at handle (file:///Users/vk/repo/yoga-issue/node_modules/graphql-yoga/esm/server.js:311:41)
ERR Error: Multipart: Boundary not found
    at new Multipart (/Users/vk/repo/yoga-issue/node_modules/busboy/lib/types/multipart.js:233:13)
    at getInstance (/Users/vk/repo/yoga-issue/node_modules/busboy/lib/index.js:33:12)
    at module.exports (/Users/vk/repo/yoga-issue/node_modules/busboy/lib/index.js:56:10)
    at /Users/vk/repo/yoga-issue/node_modules/@whatwg-node/node-fetch/cjs/Body.js:121:45
    at new Promise (<anonymous>)
    at Request.formData (/Users/vk/repo/yoga-issue/node_modules/@whatwg-node/node-fetch/cjs/Body.js:120:16)
    at parsePOSTMultipartRequest (file:///Users/vk/repo/yoga-issue/node_modules/graphql-yoga/esm/plugins/request-parser/post-multipart.js:10:37)
    at handle (file:///Users/vk/repo/yoga-issue/node_modules/graphql-yoga/esm/server.js:311:41)

Expected behavior

As a user I expect Yoga to validate multipart request and if it's malformed in any way return 200 with an error.

Screenshots or Videos

Screenshot 2024-02-27 at 12 29 51

Platform

  • OS: macOS
  • NodeJS: v18.18.0
  • "@envelop/core": "5.0.0"
  • "express": "4.18.2",
  • "graphql-yoga": "5.1.1"

Additional context

No response

@ntubrian
Copy link

same packages' verison and it happens to be the same error message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants