Skip to content

refactor(cli): remove remaining zod usage, migrate to valibot - #1389

Open
jared-outpost[bot] wants to merge 2 commits into
mainfrom
issue-1371-remove-zod-full
Open

refactor(cli): remove remaining zod usage, migrate to valibot#1389
jared-outpost[bot] wants to merge 2 commits into
mainfrom
issue-1371-remove-zod-full

Conversation

@jared-outpost

@jared-outpost jared-outpost Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

finishes the zod→valibot migration from #1370/#1388 and drops the zod dependency entirely. covers all three coupling categories in #1371 plus the ~13 self-contained schema files that were still on zod.

what changed

  • @sentry/api/zod@sentry/api/valibot (types/sentry.ts, types/feedback.ts): switched to the v*-prefixed SDK schemas and reworked the .pick/.partial/.shape/.element derivations. valibot has no .extend, so extensions are composed via object({ ...Base.entries, ... }).
  • central response validator (lib/api/infrastructure.ts + lib/api/logs.ts): z.ZodType<T>GenericSchema<unknown, T>, schema.safeParse(x)safeParse(schema, x), result.data/result.error.issuesresult.output/result.issues. the Sentry telemetry context key is renamed zod_validationschema_validation (⚠️ see note below).
  • zod-internals introspection (lib/formatters/output.ts): extractSchemaFields/zodTypeToString read zod's _def.typeName/.shape; rewritten against valibot's runtime shape (.entries/.wrapped/.options + getDescription()), including pipe/coercion type resolution and descriptions nested under wrapper schemas.
  • migrated the remaining self-contained z.object schemas (types/conversation, dashboard, replay, seer; lib/api/proguard, code-mappings, chunk-upload, dart-symbols, debug-files, preprod-artifacts, conversations, dashboards), commands/code-mappings/upload.ts, and the affected test suites' schema API usage.
  • dropped zod from packages/cli/package.json + refreshed the lockfile.

testing

  • tsc --noEmit: clean
  • biome check ./src ./test: clean (933 files)
  • generated skill docs regenerate unchanged — confirms the introspection rewrite is output-identical to the zod version
  • full test/lib, test/types, test/commands suites pass (1800+ tests)

notes for reviewers

  • telemetry key rename zod_validationschema_validation in Sentry setContext — if any dashboards/alerts key off zod_validation, they'll need updating.
  • @sentry/api zod peer: @sentry/api@0.256.0 still declares an optional zod: ^3.24.0 peer. with the CLI's direct zod dep removed, transitive zod (from AI SDKs) floats to v4, so pnpm prints a benign unmet-optional-peer warning. install and --frozen-lockfile both succeed; our usage goes through the valibot entrypoint so zod isn't needed at runtime.
  • caught + fixed two migration regressions during self-review via the generated-docs oracle: a dropped nullable on AIConversationDetailsSchema.title, and ReplayViewOutputSchema accidentally spreading the list-item base instead of the details schema (dropping clicks/replay_type).

Closes #1371

Completes the zod→valibot migration started in #1370/#1388 and drops the
`zod` dependency entirely.

Migrated the three coupling categories from #1371:
- `@sentry/api/zod` schemas in types/sentry.ts, types/feedback.ts →
  `@sentry/api/valibot` (v*-prefixed), reworking the .pick/.partial/.shape
  derivations (valibot has no .extend — composed via object spread).
- Central response validator in lib/api/infrastructure.ts + lib/api/logs.ts:
  z.ZodType → GenericSchema, schema.safeParse → safeParse(schema, data),
  result.error.issues → result.issues. Sentry telemetry context renamed
  zod_validation → schema_validation.
- Zod-internals introspection in lib/formatters/output.ts rewritten for
  valibot's runtime shape (.entries/.wrapped/.options + getDescription),
  incl. pipe/coercion type resolution and nested-wrapper descriptions.

Also migrated the ~13 self-contained z.object schema files (types/*,
lib/api/*), commands/code-mappings/upload.ts, and the test suites' schema
API usage.

Verified: tsc clean, biome clean, generated skill docs regenerate
unchanged (introspection parity), full lib/types/commands test suites pass.

Closes #1371
Comment thread packages/cli/src/lib/api/logs.ts
@BYK
BYK marked this pull request as ready for review August 7, 2026 16:43
@github-actions github-actions Bot added the risk: high PR risk score: high label Aug 7, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0108cd2. Configure here.

Comment thread packages/cli/src/lib/api/infrastructure.ts
`Unexpected response format from ${endpoint}`,
response.status,
result.error.message
result.issues.map((issue) => issue.message).join(", ")

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.

Validation errors omit failing field paths

Low Severity

Valibot issue messages do not include their paths, so joining only issue.message removes the failing field names previously present in ZodError.message. API format failures become ambiguous, especially when several fields produce identical type errors.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0108cd2. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: remove remaining Zod usage after valibot migration

0 participants