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

z.never() in request body schema throws exception #290

Open
IbrahimMohammed47 opened this issue Jan 13, 2025 · 0 comments
Open

z.never() in request body schema throws exception #290

IbrahimMohammed47 opened this issue Jan 13, 2025 · 0 comments

Comments

@IbrahimMohammed47
Copy link

IbrahimMohammed47 commented Jan 13, 2025

When I register a path, where body schema is z.never() or contains a nested attribute that is z.never, the following exception is thrown:

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<UnknownZodTypeError>".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Here is an example that causes the exception:

registry.registerPath({                           // registry: OpenAPIRegistry
    method: 'put',
    path: '/todos/{id}',
    request: {
      params: verifyIdSchema,
      body: {
        content: {
          'application/json': {
            schema: z.object({ x: z.never() })    // same if z.never() is deeply nested in the schema object
          }
        }
      }
    },
    responses: {}
  })

Same if I use z.undefined() as well

Is this a bug or am I missing something?

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