Skip to content

fix(zod): resolve global zod mutators against output workspace - #3598

Merged
melloware merged 1 commit into
orval-labs:masterfrom
chippleh1392:fix/3458-zod-output-workspace
Jun 14, 2026
Merged

fix(zod): resolve global zod mutators against output workspace#3598
melloware merged 1 commit into
orval-labs:masterfrom
chippleh1392:fix/3458-zod-output-workspace

Conversation

@chippleh1392

@chippleh1392 chippleh1392 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Global override.zod.preprocess.* and override.zod.params mutators were resolved against the config workspace, unlike operation/tag-level Zod mutators and other output mutators.

This resolves those six global Zod paths against output.workspace and adds regression coverage.

Out of scope: Global query mutators appear to share the same global-vs-operation workspace mismatch. They are intentionally excluded because this PR follows the six-path Zod scope confirmed in #3458. I can open a separate issue or PR if maintainers want query behavior aligned too.

Closes #3458

Validation:

  • vp fmt --check
  • vp run -w build:release
  • vp run -w lint
  • vp run -w lint:samples
  • vp run -w typecheck
  • vp run -w test
  • vp run -w test:snapshots
  • vp run -F orval-tests build

Summary by CodeRabbit

  • Tests

    • Added test coverage verifying Zod mutator file paths resolve correctly relative to the output workspace directory
  • Bug Fixes

    • Fixed path resolution for Zod mutator preprocess hooks and parameter configurations to correctly resolve relative to the output workspace directory instead of the base workspace

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 147f88b3-c193-4870-a4a1-a709eb6ed589

📥 Commits

Reviewing files that changed from the base of the PR and between 5440a4c and 4103444.

📒 Files selected for processing (2)
  • packages/orval/src/utils/options.test.ts
  • packages/orval/src/utils/options.ts

📝 Walkthrough

Walkthrough

In normalizeOptions, the six normalizeMutator calls covering override.zod.preprocess fields (param, query, header, body, response) and override.zod.params are changed to pass outputWorkspace instead of workspace. A new test case verifies that these paths are resolved relative to output.workspace.

Changes

Zod mutator path resolution fix

Layer / File(s) Summary
Resolve zod preprocess/params mutators against outputWorkspace
packages/orval/src/utils/options.ts, packages/orval/src/utils/options.test.ts
All normalizeMutator calls for override.zod.preprocess.{param,query,header,body,response} and override.zod.params are switched from workspace to outputWorkspace. A new Vitest test asserts that those paths are resolved relative to output.workspace (e.g., <workspace>/generated) rather than the base workspace.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • orval-labs/orval#3475: Introduces override.zod.params mutator wiring into Zod schema generation, directly intersecting with the params path resolution change here.
  • orval-labs/orval#3532: Changes how override.zod.preprocess/params mutator imports are emitted, closely related to the mutator path normalization updated in this PR.
  • orval-labs/orval#3515: Fixes target-specific preprocess mutator wiring in generateZod, directly related to the same override.zod.preprocess fields whose path resolution is corrected here.

Suggested labels

zod

Suggested reviewers

  • z4o4z
  • melloware

Poem

🐇 Hop, hop, the workspace was wrong,
outputWorkspace is where paths belong!
Six mutators now find their right home,
No more lost paths left to roam.
A test confirms the fix is strong! ✅

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(zod): resolve global zod mutators against output workspace' directly reflects the main code change, which updates the normalizeOptions function to use outputWorkspace instead of workspace for Zod mutator resolution.
Linked Issues check ✅ Passed The PR fully addresses issue #3458 by implementing the suggested fix to normalize workspace to outputWorkspace in the normalizeOptions function, ensuring consistent resolution of Zod mutators against the output workspace.
Out of Scope Changes check ✅ Passed All changes are within scope—the PR modifies normalizeOptions to resolve six Zod-related paths against outputWorkspace, directly addressing issue #3458. The author appropriately excluded similar query mutator issues from this scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chippleh1392
chippleh1392 marked this pull request as ready for review June 14, 2026 03:05
@melloware melloware added the zod Zod schema client related issue label Jun 14, 2026
@melloware

Copy link
Copy Markdown
Collaborator

@chippleh1392 yes please separate PR the behavior should be aligned!

@melloware
melloware merged commit 058cc18 into orval-labs:master Jun 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

zod Zod schema client related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: normalize workspaceoutputWorkspace in options normalization

2 participants