Skip to content

v4 beta: "Publish all locales" fails on a global whose other locale was never saved, though /validate passes #18989

Open

Description

@CxdeBits

Describe the Bug

Payload 4.0.0-beta.3, Postgres adapter, localization with two locales (nl default, en), fallback: false. The global has versions.drafts (so localizeStatus is on) and required localized fields that have a defaultValue (a function of locale).

If the global has been saved in nl but never in en, then Publish all locales in the admin fails with a ValidationError that lists every required field for locale: "en".

  • The admin's pre-check passes just before that: POST /api/globals/<slug>/validate?locale=en returns {"errors":[],"valid":true}. That check fills in the field defaults.
  • The update with publishAllLocales=true does not fill them in. It reads the newest version with locale: 'all' (getLatestGlobalVersion), takes the en values from the stored document, finds them empty, and validates those (beforeChange, docWithLocales).

Publishing en on its own works, because the form sends the defaults. After that, Publish all locales works too.

Expected: one of these.

  • Use defaults: apply defaultValue to a locale that has no stored data before validating or saving, the same as /validate and the edit form do.
  • Clear error: say that the locale has never been saved, rather than listing every required field.

As it stands, the pre-check and the save disagree.

Link to the code that reproduces this issue

Not public. The minimal setup below reproduces it.

Reproduction Steps

  1. Configure localization with nl and en and fallback: false. Add a global with versions: { drafts: true } and one required localized text field with defaultValue: ({ locale }) => locale === 'en' ? 'Hello' : 'Hallo'.
  2. In the admin, open the global in nl and click Publish in Dutch. en is never saved.
  3. Open the global in nl again, change the field, and pick Publish all locales from the publish button's menu.
  4. /validate?locale=nl and /validate?locale=en both return valid. Then POST /api/globals/<slug>?locale=nl&publishAllLocales=true returns 400, with {"path":"<field>","locale":"en","message":"This field is required."}.

Which area(s) are affected?

area: core, area: ui

Environment Info

payload: 4.0.0-beta.3
@payloadcms/db-postgres: 4.0.0-beta.3
@payloadcms/next: 4.0.0-beta.3
next: 16.4.2
node: 24

Activity

  1. added
    area: core
    area: ui
    on Oct 22, 2026
  2. removed
    area: ui
    on Oct 23, 2026
  3. morningstar620 commented on Oct 24, 2026

    @morningstar620

    +1, clear repro. Of the two options, applying defaultValue for a locale that has never been saved seems closest to what editors expect, since that's what /validate and single-locale publish already do. Whatever the choice, /validate and publishAllLocales should use the same path, so the pre-check can't pass and the publish then fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugarea: core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions