Skip to content

fix(core): don't delete the entire working directory when schemas has no path - #3753

Merged
melloware merged 1 commit into
orval-labs:masterfrom
daugvinasr:clean-true-schemas-no-path
Jul 23, 2026
Merged

fix(core): don't delete the entire working directory when schemas has no path#3753
melloware merged 1 commit into
orval-labs:masterfrom
daugvinasr:clean-true-schemas-no-path

Conversation

@daugvinasr

@daugvinasr daugvinasr commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Closes: #3752

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for schema configuration.
    • Clearer error messages are now shown when a schema path is missing, invalid, or blank.
    • Schema generation now guides you toward valid configuration options.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

normalizeSchemasOption now rejects object-form schemas configurations without a non-empty path, and a regression test verifies the resulting error.

Changes

Schema path validation

Layer / File(s) Summary
Validate and test schema paths
packages/orval/src/utils/options.ts, packages/orval/src/generate-spec.test.ts
Object-form schemas now require a non-empty trimmed schemas.path; regression coverage verifies rejection when the path is omitted.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • orval-labs/orval#3548: Updates related output.schemas normalization fields in the same options utility.

Suggested labels: security

Suggested reviewers: aqeelat, soartec-lab, titivermeesch

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: requiring a schemas path to prevent deleting the working directory.
Linked Issues check ✅ Passed The validation and regression test address the reported bug by rejecting schemas without path before clean can wipe unrelated files.
Out of Scope Changes check ✅ Passed The changes are focused on the reported schemas-path validation bug and its regression test, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@melloware melloware added the bug Something isn't working label Jul 22, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@orval/angular

bun add https://pkg.pr.new/@orval/angular@5dee52f

@orval/axios

bun add https://pkg.pr.new/@orval/axios@5dee52f

@orval/core

bun add https://pkg.pr.new/@orval/core@5dee52f

@orval/effect

bun add https://pkg.pr.new/@orval/effect@5dee52f

@orval/fetch

bun add https://pkg.pr.new/@orval/fetch@5dee52f

@orval/hono

bun add https://pkg.pr.new/@orval/hono@5dee52f

@orval/mcp

bun add https://pkg.pr.new/@orval/mcp@5dee52f

@orval/mock

bun add https://pkg.pr.new/@orval/mock@5dee52f

orval

bun add https://pkg.pr.new/orval@5dee52f

@orval/query

bun add https://pkg.pr.new/@orval/query@5dee52f

@orval/solid-start

bun add https://pkg.pr.new/@orval/solid-start@5dee52f

@orval/swr

bun add https://pkg.pr.new/@orval/swr@5dee52f

@orval/zod

bun add https://pkg.pr.new/@orval/zod@5dee52f

commit: 5dee52f

@daugvinasr
daugvinasr marked this pull request as ready for review July 22, 2026 14:00

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

🧹 Nitpick comments (1)
packages/orval/src/generate-spec.test.ts (1)

1265-1289: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Exercise the original clean: true scenario.

This test confirms path validation, but it never enables clean: true or verifies that a generated target/unrelated workspace file is preserved. Add those conditions so the regression test directly covers the deletion bug described by the PR objective.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/orval/src/generate-spec.test.ts` around lines 1265 - 1289, The test
in “generateSpec - normalizeOptions pathless schemas object” only verifies
validation and does not reproduce the clean-up regression. Extend the temporary
workspace setup with an unrelated file and enable clean: true in the output
options, then invoke the relevant generation/normalization flow and assert the
target or unrelated workspace file remains preserved while the pathless schemas
configuration is rejected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/orval/src/generate-spec.test.ts`:
- Around line 1265-1289: The test in “generateSpec - normalizeOptions pathless
schemas object” only verifies validation and does not reproduce the clean-up
regression. Extend the temporary workspace setup with an unrelated file and
enable clean: true in the output options, then invoke the relevant
generation/normalization flow and assert the target or unrelated workspace file
remains preserved while the pathless schemas configuration is rejected.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 687d791c-0a7f-46d1-8919-c3a72ebc630c

📥 Commits

Reviewing files that changed from the base of the PR and between 7879bc4 and 5dee52f.

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

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clean: true deletes the entire working directory when schemas has no path

2 participants