Skip to content

fix: skip validation for unpublish operations with localized required fields#16120

Merged
PatrikKozak merged 5 commits intopayloadcms:mainfrom
omar-y-abdi:fix/unpublish-localized-required-validation
Apr 1, 2026
Merged

fix: skip validation for unpublish operations with localized required fields#16120
PatrikKozak merged 5 commits intopayloadcms:mainfrom
omar-y-abdi:fix/unpublish-localized-required-validation

Conversation

@omar-y-abdi
Copy link
Copy Markdown
Contributor

@omar-y-abdi omar-y-abdi commented Mar 31, 2026

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 #15651


… 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
@PatrikKozak PatrikKozak self-assigned this Mar 31, 2026
@PatrikKozak PatrikKozak self-requested a review March 31, 2026 22:43
@PatrikKozak
Copy link
Copy Markdown
Contributor

Hey @omar-y-abdi - thank you for the PR!

Most of it looked good but I ended up removing this additional check:

& !hasDraftValidationEnabled(collectionConfig))

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 PatrikKozak merged commit 24b9e13 into payloadcms:main Apr 1, 2026
316 of 318 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

🚀 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unpublishing documents with required localized fields fails with validation error

2 participants