Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Jun 20, 2025

fixes #2025

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

📝 Walkthrough

Walkthrough

A new validation option, inputOnlyValidationForUpdate, was introduced to control whether schema validation on update operations should apply only to the input data or to the entire entity. The core logic in checkPolicyForUnique was updated to honor this option, and a regression test was added to verify the new behavior.

Changes

File(s) Change Summary
packages/runtime/src/types.ts Added ValidationOptions type and optional validation property to EnhancementOptions.
packages/runtime/src/enhancements/node/policy/policy-utils.ts Modified checkPolicyForUnique to skip schema validation if inputOnlyValidationForUpdate is true.
tests/regression/tests/issue-2025.test.ts Added regression test for conditional validation on update with/without inputOnlyValidationForUpdate option.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Regression Test
    participant Prisma as Enhanced Prisma Client
    participant Policy as Policy Layer
    participant Validator as Schema Validator

    Test->>Prisma: Create User with invalid email (no validation)
    Test->>Prisma: Update User with inputOnlyValidationForUpdate=true
    Prisma->>Policy: Check policy for update
    Policy->>Validator: Validate input only (skips full entity validation)
    Validator-->>Policy: Validation passes
    Policy-->>Prisma: Allow update
    Prisma-->>Test: Update succeeds

    Test->>Prisma: Update User with default validation
    Prisma->>Policy: Check policy for update
    Policy->>Validator: Validate entire entity
    Validator-->>Policy: Validation fails (invalid email)
    Policy-->>Prisma: Reject update
    Prisma-->>Test: Update fails
Loading

Assessment against linked issues

Objective Addressed Explanation
Add a switch to validate only updated fields on update operations (#2025)
Default behavior should remain full entity validation unless the switch is enabled (#2025)
Provide a way for developers to opt-in to input-only validation via configuration (#2025)
Regression test to verify both input-only and full validation behaviors (#2025)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 485be72 and 34e99b7.

📒 Files selected for processing (3)
  • packages/runtime/src/enhancements/node/policy/policy-utils.ts (1 hunks)
  • packages/runtime/src/types.ts (2 hunks)
  • tests/regression/tests/issue-2025.test.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: OSSAR-Scan
  • GitHub Check: build-test (20.x)
  • GitHub Check: build-test (20.x)
  • GitHub Check: dependency-review
  • GitHub Check: build-test (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/runtime/src/types.ts (2)

144-147: LGTM! Well-integrated validation options.

The new validation property is properly integrated into the EnhancementOptions type with appropriate optional typing.


218-233: Excellent documentation and type design.

The ValidationOptions type is well-defined with:

  • Clear documentation explaining the behavioral difference
  • Explicit default value (false) ensuring backward compatibility
  • Descriptive property name that clearly indicates its purpose
packages/runtime/src/enhancements/node/policy/policy-utils.ts (1)

942-942: ```shell
#!/bin/bash
TARGET="packages/runtime/src/enhancements/node/policy/policy-utils.ts"
echo "Locating function definition:"
grep -R "checkPolicyForUnique" -n $TARGET

echo ""
echo "Showing lines 830 to 980 for context:"
sed -n '830,980p' $TARGET


</details>
<details>
<summary>tests/regression/tests/issue-2025.test.ts (1)</summary>

`3-42`: **Excellent regression test coverage.**

The test effectively demonstrates the new functionality by:
1. Creating invalid data using raw Prisma (bypassing validation)
2. Testing update with `inputOnlyValidationForUpdate: true` - expects success
3. Testing update with default behavior - expects rejection

This clearly validates that the new option works as intended while maintaining backward compatibility.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIgAzEmoACm58L3gGWQBKLjRaekQSXHEMImQCSAk0DNpqEn4ML3l4DE9cSDrcNEh4/D5sbi6SUNjIAHc0ZAcBZnUaejkI2AbsIr5ZZgYATnRkW0gMRwFKSAAmAEYAVjONGBXGWExSdAL/RCLkJAcGszOABjO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Qhm3UWaeg5vYNpbo/6fGOWAcFRA0oGDwE1Luwl9Im0dGoDQE0RFRKIEmWCYY46z3m2nWIa2yCGj+FnGeJYwUpUAMhKqSSYCngdHiN4XwSHbZeHttGW95ZozoLKmc/omc/TyEft4TQnE9LjLDGsKolAPIiNEkK4diGQmlQ2Wgd+fAx5kPeqJ0Sbc2gdSrep+ktbhi+wNmi0SJLlBzitOW2jQmYIaVA8KXUl1Z4SPxowz6zDfr43YQ8XGzggt+wptDGIsNBGZERpEERqMBnRyVQ4dQBklDpV1CcZI5qZnnEBFcc14QNCleyCnXxPQlU+iKBW3AuXCnFPVMVvYshEKQGSNkSAABePQkAADepWNAAF9yuCaWVc4Knkq49vySBEgwyPjqjKXNmZ1TCt1JCHU8OzT2Y5K/FuRG/ZBxHhHKeMcLAJxXjQDeBwTFHyj2fCuNQb4NyfgMId8c6gAD6bpEDfb8kGOg32C3Qw/AdnskAADMAAWEg2xtgCAAOzbCh0jhg8QocADYse0ChxcLHVwscMFoAT7YZx4jxAYAIVHaA4cw4YGcAQ4PvxQC+7gX7y0Af7S8sGb7fZwdAA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=zenstackhq/zenstack&utm_content=2152):

> ‼️ **IMPORTANT**
> Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@ymc9 ymc9 merged commit 2141d2e into dev Jun 20, 2025
11 checks passed
@ymc9 ymc9 deleted the feat/input-only-validation branch June 20, 2025 11:14
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