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

Unexpected MIME type causes prism to crash #2605

Open
RobertCraigie opened this issue Sep 12, 2024 · 0 comments
Open

Unexpected MIME type causes prism to crash #2605

RobertCraigie opened this issue Sep 12, 2024 · 0 comments

Comments

@RobertCraigie
Copy link

Current Behavior

The mock server crashes when a request comes in for an endpoint that looks like this

        "requestBody": {
          "description": "...",
          "content": {
            "undefined": {
              "schema": {
                "type": "object",
                "properties": {}
              }
            }
          }
        },

With this error

/Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/whatwg-mimetype/lib/mime-type.js:15
      throw new Error(`Could not parse MIME type string "${string}"`);
            ^
Error: Could not parse MIME type string "undefined"
    at new MIMEType (/Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/whatwg-mimetype/lib/mime-type.js:15:13)
    at parseMIMEHeader (/Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/@stoplight/prism-http/dist/validator/validators/headers.js:9:22)
    at /Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/@stoplight/prism-http/dist/validator/index.js:27:41
    at /Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/fp-ts/lib/Either.js:66:101
    at /Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/fp-ts/lib/function.js:366:46
    at pipe (/Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/fp-ts/lib/function.js:305:23)
    at validateInputBody (/Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/@stoplight/prism-http/dist/validator/index.js:24:87)
    at /Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/@stoplight/prism-http/dist/validator/index.js:56:142
    at /Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/fp-ts/lib/Either.js:844:60
    at pipe (/Users/robert/.npm/_npx/61be57b7fb4720a9/node_modules/fp-ts/lib/function.js:303:23)

Expected Behavior

I would expect the mock server to return an error response instead of crashing.

Possible Workaround/Solution

Workaround in my case is to just fix the mime type. I'm mainly just opening this issue as it'd be great for Prism to be more crash-resistant!

Steps to Reproduce

Sorry I don't have a full reproduction, hopefully the aforementioned endpoint definition is helpful.

Environment

  • Version used: v5.11.0
  • Environment name and version (e.g. Chrome 39, node.js 5.4): nodejs v21
  • Operating System and version (desktop or mobile): MacOS
  • Link to your environment/workspace/project: N/A
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

No branches or pull requests

1 participant