Skip to content

fix(valibot): upgrade @valibot/to-json-schema to 1.8.0 - #2009

Merged
dinwwwh merged 1 commit into
middleapi:mainfrom
dinwwwh:claude/valibot-tojsonschema-upgrade-a5dcd8
Sep 12, 2026
Merged

fix(valibot): upgrade @valibot/to-json-schema to 1.8.0#2009
dinwwwh merged 1 commit into
middleapi:mainfrom
dinwwwh:claude/valibot-tojsonschema-upgrade-a5dcd8

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Sep 12, 2026

Copy link
Copy Markdown
Member

Upgrades @valibot/to-json-schema from 1.7.1 to 1.8.0. Generated OpenAPI documents are now reproducible: 1.8.0 allocates $defs reference ids per conversion rather than from a module-global counter, so regenerating a document in the same process no longer renames its components. No oRPC source changes were needed; ValibotToJsonSchemaConverter is drop-in compatible.

Fixes

  • OpenAPI output is stable across generations. A document with two recursive Valibot schemas previously produced components.schemas named 0,1,2,3, then 4,5,6,7 on the next call in the same process.
  • A supplied definition is no longer silently overwritten. With definitions: { 0: PlanetSchema }, an anonymous recursive schema claimed $defs/0 and replaced Planet, leaving $refs resolving to the wrong schema.
  • Documents are smaller: that same router drops from four components to two, since identical input and output conversions now share one.
  • Repeated constraints keep the stricter bound instead of the last one written. v.pipe(v.number(), v.minValue(5), v.minValue(1)) previously widened to minimum: 1.

Compatibility

@orpc/valibot's valibot peer range moves from >=1.0.0 to >=1.5.0, matching the peer 1.8.0 declares for itself.

This one is worth a reviewer's judgement, because valibot 1.4.x does still work in practice: @valibot/to-json-schema has no runtime imports from valibot, and the full suite passes on 1.4.2 with 1.8.0 installed. The bump makes the advertised range deliverable rather than fixing a break. Consumers on 1.4.x already get an unmet-peer warning today from the transitive dependency while the published >=1.0.0 claims support, and neither pnpm nor npm hard-fails on it.

Housekeeping

Pruned the minimumReleaseAgeExclude entries that have aged past the gate, as that list's own comment asks, leaving only the new @valibot/to-json-schema@1.8.0. A full pnpm install passes and pnpm re-adds none of them.

Testing

  • pnpm vitest run — 3353 passed, 47 skipped
  • pnpm type:check — clean
  • pnpm lint — clean
  • pnpm peers check — no unmet valibot peer

Both fixes were verified by running the same code against 1.7.1 and 1.8.0. A scratch consumer project also confirmed that with the currently published @orpc/valibot@2.0.0-beta.35, a valibot 1.4.x install already resolves @valibot/to-json-schema@1.8.0 and warns once pnpm's release-age gate lapses.

Noted separately while reviewing, pre-existing and untouched here: converting a v.set() or v.map() whose element schema is recursive emits a $defs block nested under items while the $ref to it stays root-absolute, so that reference dangles.

1.8.0 allocates `$defs` reference ids per conversion and reserves ids
already present in `definitions`, instead of drawing from a module-global
counter. That makes generated OpenAPI documents reproducible and stops an
anonymous recursive schema from overwriting a supplied definition.

Raise `@orpc/valibot`'s `valibot` peer floor to `>=1.5.0` to match the
peer requirement 1.8.0 now declares, and prune the
`minimumReleaseAgeExclude` entries that have aged past the gate.
@pkg-pr-new

pkg-pr-new Bot commented Sep 12, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@2009

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@2009

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@2009

@orpc/client

npm i https://pkg.pr.new/@orpc/client@2009

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@2009

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@2009

@orpc/experimental-effect

npm i https://pkg.pr.new/@orpc/experimental-effect@2009

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@2009

@orpc/hibernation

npm i https://pkg.pr.new/@orpc/hibernation@2009

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@2009

@orpc/experimental-msw

npm i https://pkg.pr.new/@orpc/experimental-msw@2009

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@2009

@orpc/next

npm i https://pkg.pr.new/@orpc/next@2009

@orpc/node

npm i https://pkg.pr.new/@orpc/node@2009

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@2009

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@2009

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@2009

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@2009

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@2009

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@2009

@orpc/server

npm i https://pkg.pr.new/@orpc/server@2009

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@2009

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@2009

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@2009

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@2009

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@2009

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@2009

commit: 0197834

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 30 untouched benchmarks


Comparing dinwwwh:claude/valibot-tojsonschema-upgrade-a5dcd8 (0197834) with main (5c76a6a)

Open in CodSpeed

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — the bump, peer-range adjustment, and lockfile are consistent. One non-blocking suggestion on regression coverage.

Reviewed changes

  • @valibot/to-json-schema ^1.5.0^1.8.0 in packages/valibot/package.json, with the lockfile importer specifier, integrity/peer block, and snapshot updated in lockstep.
  • valibot peer >=1.0.0>=1.5.0, matching the peer @valibot/to-json-schema@1.8.0 declares and the package's own ^1.5.0 devDependency.
  • minimumReleaseAgeExclude pruning in pnpm-workspace.yaml — aged-out entries removed, only @valibot/to-json-schema@1.8.0 kept.

I reproduced the upstream behavior against the installed 1.8.0: repeated conversions now return byte-identical output, a supplied definitions entry is no longer clobbered, and v.pipe(v.number(), v.minValue(5), v.minValue(1)) keeps minimum: 5. pnpm vitest run packages/valibot passes (20 tests). The peer bump follows the repo's >= lower-bound convention (zod >=4.5.0, effect >=4.0.0-beta.90) and every workspace valibot pin is ^1.5.0, so nothing else is affected. The rationale for raising the peer floor despite 1.4.x still working is sound — the transitive peer already warns on 1.4.x, so this just makes the advertised range honest.

ℹ️ The reproducibility fix isn't pinned by a test

The PR's headline guarantee — a document regenerated in the same process keeps its component names — is currently only verified by the author's manual runs. Since the dependency is pinned to ^1.8.0, a future 1.8.x/1.9.x minor that reintroduces global $defs allocation would silently regress it. A small test in packages/valibot/src/converter.test.ts that converts the same recursive schema twice and asserts deep equality would lock the behavior in.

Technical details
# Missing regression coverage for reproducible `$defs` allocation

## Affected sites
- packages/valibot/src/converter.test.ts — has no test exercising repeated conversions of the same recursive schema.

## Required outcome
- A test that converts a recursive Valibot schema (with `definitions`) twice via `ValibotToJsonSchemaConverter` and asserts both results are deeply equal, so a dependency regression in the `^1.8.0` range is caught by CI.

## Suggested approach (optional)
- Add to the existing `valibotToJsonSchemaConverter` describe block; no production code change needed.

Pullfrog  | Fix it ➔View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@dinwwwh
dinwwwh merged commit 8be90cb into middleapi:main Sep 12, 2026
11 checks passed
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.

1 participant