fix(dashboard): treat readonly custom fields as optional in Zod schema - #5057
fix(dashboard): treat readonly custom fields as optional in Zod schema#5057Ryrahul wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughReadonly custom fields now receive optional and nullable schema modifiers when Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
HouseinIsProgramming
left a comment
There was a problem hiding this comment.
Nice one, clean fix, and thanks for adding a test.
One thing before I approve: the test covers the readonly case but not the opposite one. I had a fiddle locally, and if you swap the whole condition for if (true) the spec still passes. So nothing's actually guarding the non-nullable behaviour any more.
Worth adding a case where a plain nullable: false field (no readonly) still gets rejected.
Readonly custom fields with nullable: false produced an unsatisfiable Zod schema, permanently disabling the Create/Update button. Fixes by adding || customField.readonly to the nullable check in applyCustomFieldModifiers().
24147cc to
34e4e11
Compare
Breaking changes
No breaking changes. This is a purely additive fix — the only behavioral change is that readonly custom fields with
nullable: falseno longer block form submission. All existing validation behavior for non-readonly fields is unchanged.Summary
Fixes #5045
When a custom field is configured with both
readonly: trueandnullable: false, the Dashboard's Zod validation schema treats it as required. But readonly fields can never receive a value from the form:Create*Input/Update*InputGraphQL typesremoveReadonlyAndLocalizedCustomFields()before submittingThe result is an unsatisfiable schema — the form is permanently invalid and the Create/Update button stays disabled.
Fix: A single-condition change in
applyCustomFieldModifiers()— readonly fields are now always treated as optional regardless of theirnullablesetting.Checklist
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.