Skip to content

Fix: update zod-openapi to 5.4.5#151

Closed
gaetansenn wants to merge 1 commit into
mcampa:masterfrom
gaetansenn:patch-1
Closed

Fix: update zod-openapi to 5.4.5#151
gaetansenn wants to merge 1 commit into
mcampa:masterfrom
gaetansenn:patch-1

Conversation

@gaetansenn
Copy link
Copy Markdown

Upgrade zod-openapi library

Cannot convert undefined or null to object
apps/middleware dev: at Function.entries ()
apps/middleware dev: at override (file:///Users/gaetansenn/Development/aromazone/middleware/node_modules/.pnpm/zod-openapi@5.4.3_zod@4.1.13/node_modules/zod-openapi/dist/components-DV_-zLJ6.js:206:39)
apps/middleware dev: at JSONSchemaGenerator.override (file:///Users/gaetansenn/Development/aromazone/middleware/node_modules/.pnpm/zod-openapi@5.4.3_zod@4.1.13/node_modules/zod-openapi/dist/components-DV_-zLJ6.js:372:4)

Upgrade zod-openapi library 

Cannot convert undefined or null to object
apps/middleware dev:       at Function.entries (<anonymous>)
apps/middleware dev:       at override (file:///Users/gaetansenn/Development/aromazone/middleware/node_modules/.pnpm/zod-openapi@5.4.3_zod@4.1.13/node_modules/zod-openapi/dist/components-DV_-zLJ6.js:206:39)
apps/middleware dev:       at JSONSchemaGenerator.override (file:///Users/gaetansenn/Development/aromazone/middleware/node_modules/.pnpm/zod-openapi@5.4.3_zod@4.1.13/node_modules/zod-openapi/dist/components-DV_-zLJ6.js:372:4)
mcampa added a commit that referenced this pull request May 22, 2026
Resolves the crash demonstrated in the previous commit. zod-openapi 5.4.4
fixes the discriminated union override path (reading anyOf instead of
oneOf), 5.4.5 fixes type declarations, and 5.4.6 addresses additional
Zod 4.3+ "cannot be represented in OpenAPI" compatibility issues.

Also relaxes the zod devDep pin to ^4.1.13 so the test continues to
exercise the previously-broken code path while allowing forward minor
upgrades.

Snapshot update is upstream zod behavior: the v4.1 UUID regex now
includes the max UUID (ffffffff-ffff-ffff-ffff-ffffffffffff).

Supersedes #151.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mcampa
Copy link
Copy Markdown
Owner

mcampa commented May 22, 2026

Hi @gaetansenn — thanks for catching this! I've opened #162 which builds on your version bump:

  • Goes to zod-openapi 5.4.6 (latest patch), which includes the actual discriminated-union fix from 5.4.4 (samchungy/zod-openapi#556) plus 5.4.5 type fixes and 5.4.6 zod 4.3+ compatibility fixes
  • Adds a regression test that reproduces the exact `Cannot convert undefined or null to object` stack trace from your report
  • Pins the zod devDep to `^4.1.13` so the test keeps exercising the previously-broken code path

Closing this in favor of #162 — full credit to you for the report. 🙏

@mcampa mcampa closed this May 22, 2026
mcampa added a commit that referenced this pull request May 22, 2026
Pin zod to 4.1.13 (where discriminated unions began emitting anyOf
instead of oneOf) and add a test that calls generateOpenApiDocument on a
router with a discriminated union input. With zod-openapi 5.4.2 the test
fails with "Cannot convert undefined or null to object" in
JSONSchemaGenerator.override, matching the stack trace in #151.

Verified the test passes after bumping zod-openapi to 5.4.5, which is
what #151 proposes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mcampa added a commit that referenced this pull request May 22, 2026
Resolves the crash demonstrated in the previous commit. zod-openapi 5.4.4
fixes the discriminated union override path (reading anyOf instead of
oneOf), 5.4.5 fixes type declarations, and 5.4.6 addresses additional
Zod 4.3+ "cannot be represented in OpenAPI" compatibility issues.

Also relaxes the zod devDep pin to ^4.1.13 so the test continues to
exercise the previously-broken code path while allowing forward minor
upgrades.

Snapshot update is upstream zod behavior: the v4.1 UUID regex now
includes the max UUID (ffffffff-ffff-ffff-ffff-ffffffffffff).

Supersedes #151.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mcampa added a commit that referenced this pull request May 22, 2026
5.4.0–5.4.3 crash when generating OpenAPI docs for routers with
discriminated union inputs on zod >=4.1.13 (see #151). Tightening the
peer dep prevents consumers from installing a known-broken range.

Addresses Copilot review on #162.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mcampa added a commit that referenced this pull request May 22, 2026
…st (supersedes #151) (#162)

* test: reproduce zod-openapi discriminated union crash from #151

Pin zod to 4.1.13 (where discriminated unions began emitting anyOf
instead of oneOf) and add a test that calls generateOpenApiDocument on a
router with a discriminated union input. With zod-openapi 5.4.2 the test
fails with "Cannot convert undefined or null to object" in
JSONSchemaGenerator.override, matching the stack trace in #151.

Verified the test passes after bumping zod-openapi to 5.4.5, which is
what #151 proposes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: bump zod-openapi to 5.4.6 to fix discriminated union crash

Resolves the crash demonstrated in the previous commit. zod-openapi 5.4.4
fixes the discriminated union override path (reading anyOf instead of
oneOf), 5.4.5 fixes type declarations, and 5.4.6 addresses additional
Zod 4.3+ "cannot be represented in OpenAPI" compatibility issues.

Also relaxes the zod devDep pin to ^4.1.13 so the test continues to
exercise the previously-broken code path while allowing forward minor
upgrades.

Snapshot update is upstream zod behavior: the v4.1 UUID regex now
includes the max UUID (ffffffff-ffff-ffff-ffff-ffffffffffff).

Supersedes #151.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: raise zod-openapi peer dep to ^5.4.4

5.4.0–5.4.3 crash when generating OpenAPI docs for routers with
discriminated union inputs on zod >=4.1.13 (see #151). Tightening the
peer dep prevents consumers from installing a known-broken range.

Addresses Copilot review on #162.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mcampa mcampa mentioned this pull request May 22, 2026
4 tasks
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.

2 participants