fix: skip validation for unpublish operations with localized required fields#16120
Merged
PatrikKozak merged 5 commits intopayloadcms:mainfrom Apr 1, 2026
Conversation
… fields
Unpublish sends only { _status: 'draft' } without field data. With
localization.fallback: false, required localized fields fail validation
since values cannot be resolved. Unpublish is metadata-only, so field
validation is unnecessary.
Fixes payloadcms#15651
…sh-localized-required-validation
Contributor
|
Hey @omar-y-abdi - thank you for the PR! Most of it looked good but I ended up removing this additional check: unpublishing should skip validation regardless of the draftValidation config option, since data isn't explicitly being updated - only the status field changes. I also went ahead and cleaned up the tests a bit but overall they were good - thanks again! I'll get this merged once CI passes |
PatrikKozak
approved these changes
Apr 1, 2026
Contributor
|
🚀 This is included in version v3.82.0 |
milamer
pushed a commit
to milamer/payload
that referenced
this pull request
Apr 20, 2026
… fields (payloadcms#16120) ## Problem Unpublishing documents with `required: true` + `localized: true` fields fails with a validation error when `localization.fallback: false`. The `UnpublishButton` sends only `{ _status: 'draft' }` with `unpublishAllLocales=true` but no field data, causing `beforeChange` validation to fail on missing required fields. ## Solution Added `unpublishAllLocales` to the `skipValidation` condition in `beforeChange` for both collections and globals — same pattern already used for `isSavingDraft`. ## Why Unpublish is a metadata-only operation (changing `_status`). Field validation is unnecessary since data already exists in the database. Fixes payloadcms#15651 --------- Co-authored-by: Patrik Kozak <35232443+PatrikKozak@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Unpublishing documents with
required: true+localized: truefields fails with a validation error whenlocalization.fallback: false.The
UnpublishButtonsends only{ _status: 'draft' }withunpublishAllLocales=truebut no field data, causingbeforeChangevalidation to fail on missing required fields.Solution
Added
unpublishAllLocalesto theskipValidationcondition inbeforeChangefor both collections and globals — same pattern already used forisSavingDraft.Why
Unpublish is a metadata-only operation (changing
_status). Field validation is unnecessary since data already exists in the database.Fixes #15651