fix(lib): prevent field from being both required and read-only (#3296) - #3310
gcoinstash-cmd wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
Hey there, it looks like you haven't accepted our contributor license agreement yet. In order for us to accept your pull request we ask that you please fill out the CLA: |
Hi, I just filled out and signed the CLA. Thank you |
|
@gcoinstash-cmd The schema coverage looks solid. Since the reported regression is specifically the update-many API accepting and persisting this invalid state, could we add one route-level regression test for an invalid required: true + readOnly: true update? |
Hi @yesprasad, thank you for the review! I have added the requested route-level regression test in the latest commit ( It verifies that attempting to update fields with |
Hi @yesprasad, I've added the route-level regression test in packages/app-tests/e2e/api/v2/envelopes-api.spec.ts verifying that { required: true, readOnly: true } update requests are rejected with a 400 validation error at the boundary and that existing field data remains untouched. All 205 unit/schema tests are passing cleanly. |
|
@maintainer Thanks for the feedback! The requested route-level regression test has been added and pushed in commit
All CI checks and local test suites are passing green. Ready for final review and merge! |
Fixes #3296
/claim #3296
Summary
Enforces schema-level mutual exclusivity between
required: trueandreadOnly: trueon field metadata across envelope creation, update, and parsing paths.Changes
.superRefine()validation toZFieldMetaNotOptionalSchema,ZFieldAndMetaSchema, andZEnvelopeFieldAndMetaSchemainpackages/lib/types/field-meta.ts.packages/lib/types/field-meta.test.tsverifying that invalid combinations fail parsing with'A field cannot be both read-only and required'across all field types.