Skip to content

#129 Don't silently strip unknown fields in content and user zod schemas#136

Merged
pnicolli merged 3 commits into
mainfrom
129-zod_validation_unconfigured_fields_error
Jun 12, 2026
Merged

#129 Don't silently strip unknown fields in content and user zod schemas#136
pnicolli merged 3 commits into
mainfrom
129-zod_validation_unconfigured_fields_error

Conversation

@jmevissen

Copy link
Copy Markdown
Contributor

Problem

Change notes entered in the @@edit form never reached the version history.
The edit route forwards the note correctly — the loss happens in
@plone/client: updateContent builds the PATCH body from the zod-parsed
args, and zod's default object mode silently strips every key the schema does
not declare. changeNote was not declared, so it was dropped before the
request was sent.

This affected more than the change note: any field not whitelisted in
createContentDataSchema/updateContentDataSchema was discarded on save —
including all fields of custom dexterity types. The user schemas had the same
issue for custom member properties.

Change

  • createContentDataSchema / updateContentDataSchema: added .passthrough()
    and declared changeNote.
  • createUserDataSchema / updateUserDataSchema: added .passthrough().

Declared fields are still validated exactly as before (a mistyped declared
field still throws); .passthrough() only stops unknown keys from being
stripped, leaving the backend as the authority on which fields exist.
Schemas for fixed-protocol payloads (copy/move, comments, workflow) are
deliberately unchanged, and registry.ts already used z.record.

Tests

  • src/validation/passthrough.test.ts: unit tests — unknown fields survive
    parsing on content and user schemas, declared fields still validated.
  • src/restapi/content/update.test.ts: integration test asserting the
    changeNote lands as the version comment in @history.

Caution

The Volto Team has suspended its review of new pull requests from first-time contributors until the release of Plone 7, which is preliminarily scheduled for the second quarter of 2026.
Read details.



If your pull request closes an open issue, include the exact text below, immediately followed by the issue number. When your pull request gets merged, then that issue will close automatically.

Closes #129

@jmevissen jmevissen requested a review from pnicolli June 12, 2026 13:08
@pnicolli pnicolli requested a review from sneridagh June 12, 2026 13:17

@pnicolli pnicolli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this a little bit of extra thought and came up with a few changes I would make. Overall, this is very much needed, thanks!

Comment thread packages/client/src/validation/content.ts
Comment thread packages/client/src/restapi/content/update.test.ts Outdated
Comment thread packages/client/src/validation/passthrough.test.ts Outdated
Comment thread packages/client/src/validation/passthrough.test.ts Outdated
@jmevissen jmevissen requested a review from pnicolli June 12, 2026 14:01
@pnicolli pnicolli merged commit bec65db into main Jun 12, 2026
29 of 30 checks passed
@pnicolli pnicolli deleted the 129-zod_validation_unconfigured_fields_error branch June 12, 2026 14:37
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.

Change notes entered in the edit form are never submitted

2 participants