Skip to content

fix: translate schema validation errors and field labels - #19486

Draft
DanRibbens wants to merge 2 commits into
mainfrom
fix/schema-validation-messages
Draft

DanRibbens wants to merge 2 commits into
mainfrom
fix/schema-validation-messages

Conversation

@DanRibbens

@DanRibbens DanRibbens commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Written with AI

Description

Schema validation currently exposes schema-library messages such as Invalid input: expected number, received string without configured field labels. Return translated Payload validation messages and configured labels while preserving the existing machine-readable error paths.

Deferred follow-up tracked in PYLD-5204. Keep this PR in draft for later review. It is outside the content branching release scope and does not block that feature or #19380.

Extracted from #19380 as an independent improvement targeting main. This applies to shared collection/global schema validation and requires no content branching configuration. Branch merge behavior and error presentation remain in #19380.

Changes

  • Map missing values, invalid numbers, invalid booleans, invalid selections, and other schema failures to existing Payload translation keys.
  • Resolve string, function, and translated field labels with getTranslation, including array/block row numbers and nested field labels.
  • Use the existing Lexical and MCP integration assertions to verify translated messages, configured labels, nested block row context, and unchanged machine-readable field paths. No standalone unit tests or new fixtures are added.

For example, data.numberField now reports Please enter a valid number. with its configured Number Field label. Validation acceptance rules and error paths are unchanged. Error wording is covered by the wording exception in the repository versioning policy.

Test Plan

  • Existing targeted MongoDB integration regressions: 7 passed across the Lexical and MCP suites. Confirmed all 7 fail against unmodified main and pass with the fix.
  • Full MongoDB Lexical and MCP integration suites previously passed with the same production code: 367 passed, 1 skipped across 2 passing files. After removing the standalone unit test, the 7 affected integration cases were rerun successfully.
  • Core TypeScript check passed after building the translations project reference.
  • Targeted validator lint, changed-file formatting, and git diff --check passed.
  • Local checks used Node 22.23.1; the repository declares Node >=24.22.1. Other database adapters were not rerun locally.

Accessibility assessment

Assessed WCAG 2.2 A/AA error identification (3.3.1) and error suggestion (3.3.3). Automated evidence verifies translated descriptions, configured field identification, row context, and correction wording at the validator/API level. This extraction changes no markup, focus, keyboard handling, or live-region behavior. Rendered error association, visual presentation, and screen-reader announcements remain unverified; no browser/axe or assistive-technology conformance is claimed.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Entity validation errors now use request translations and configured field labels. The utility selects messages based on the issue type and resolved value, and follows configured fields through nested objects, array rows, and blocks.

Changes: Entity Validation Error Formatting

Layer / File(s) Summary
Resolve translated messages and field labels
packages/payload/src/utilities/entityInputSchema/validateEntityData.ts
Validation messages use request translations. Field labels are resolved across nested fields, array rows, and blocks.
Apply error details and update expectations
packages/payload/src/utilities/entityInputSchema/validateEntityData.ts, test/lexical/lexical.int.spec.ts, test/plugin-mcp/int.spec.ts
Validation errors include the resolved message and label while retaining the formatted path. Integration tests expect the updated error text.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • payloadcms/payload#19208: Handles non-string field and configuration labels in user-facing messages through a separate message-generation path.
  • payloadcms/payload#19209: Resolves non-string labels for user-facing messages in a separate validation-message path.

Suggested reviewers: alessiogr, jarrodmflesch

Merge Risk: Low · up to c748f

Validation errors may show an incorrect field label for configurations with overlapping block slugs. This is a bounded issue that can be addressed as a follow-up.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly summarizes the main change: translating schema validation errors and adding field labels.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description explains the changes to translated validation messages, configured field labels, and preserved error paths. It matches the changeset.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 09b6b84 and c748ff4.

Files selected for processing: 3

  • packages/payload/src/utilities/entityInputSchema/validateEntityData.ts
  • test/lexical/lexical.int.spec.ts
  • test/plugin-mcp/int.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖

Meta File Out File Size (raw) Note
packages/next/meta_index.json esbuild/index.js 279.40 KB ✅ No change
packages/payload/meta_index.json esbuild/index.js 1.99 MB ⚠️ +1.39 KB (+0.1%)
packages/payload/meta_shared.json esbuild/exports/shared.js 547.32 KB ✅ No change
packages/richtext-lexical/meta_client.json esbuild/exports/client_optimized/index.js 302.50 KB ✅ No change
packages/ui/meta_client.json esbuild/exports/client_optimized/index.js 1.39 MB ✅ No change
packages/ui/meta_shared.json esbuild/exports/shared_optimized/index.js 19.46 KB ✅ No change
Largest paths These visualization shows top 20 largest paths in the bundle.

Meta file: packages/next/meta_index.json, Out file: esbuild/index.js

Path Size
../../node_modules ${{\color{Goldenrod}{ ████████████████████████▋ }}}$ 98.7%, 272.71 KB
dist/adapters/router.js ${{\color{Goldenrod}{ }}}$ 0.4%, 1.00 KB
dist/adapters/server.js ${{\color{Goldenrod}{ }}}$ 0.2%, 533 B
dist/adapters/layout.js ${{\color{Goldenrod}{ }}}$ 0.2%, 529 B
dist/adapters/views.js ${{\color{Goldenrod}{ }}}$ 0.2%, 469 B
dist/adapters/UnmountWhenHidden ${{\color{Goldenrod}{ }}}$ 0.2%, 449 B
dist/utilities/initAdminContext.js ${{\color{Goldenrod}{ }}}$ 0.1%, 366 B
dist/utilities/selectiveCache.js ${{\color{Goldenrod}{ }}}$ 0.1%, 263 B
dist/esbuildEntry.js ${{\color{Goldenrod}{ }}}$ 0.0%, 0 B

Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js

Path Size
../../node_modules ${{\color{Goldenrod}{ ████████████████▊ }}}$ 67.1%, 1.33 MB
dist/collections/operations ${{\color{Goldenrod}{ ▉ }}}$ 3.5%, 68.76 KB
dist/fields/hooks ${{\color{Goldenrod}{ ▋ }}}$ 2.5%, 48.41 KB
dist/uploads/fileVersioning ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 22.32 KB
dist/globals/operations ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 19.12 KB
dist/auth/operations ${{\color{Goldenrod}{ ▏ }}}$ 0.9%, 18.06 KB
dist/utilities/configToJSONSchema.js ${{\color{Goldenrod}{ ▏ }}}$ 0.8%, 16.17 KB
dist/queues/operations ${{\color{Goldenrod}{ ▏ }}}$ 0.7%, 14.33 KB
dist/fields/config ${{\color{Goldenrod}{ ▏ }}}$ 0.7%, 13.78 KB
dist/uploads/generateFileData.js ${{\color{Goldenrod}{ ▏ }}}$ 0.7%, 12.91 KB
dist/utilities/telemetry ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 12.73 KB
dist/uploads/transformers ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 12.23 KB
dist/collections/config ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 12.21 KB
dist/uploads/transformState ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 11.28 KB
dist/fields/validations.js ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 10.33 KB
dist/cli/commands ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 9.93 KB
dist/utilities/entityInputSchema ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 9.41 KB
dist/config/orderable ${{\color{Goldenrod}{ }}}$ 0.4%, 8.78 KB
dist/uploads/fetchAPI-multipart ${{\color{Goldenrod}{ }}}$ 0.4%, 8.39 KB
dist/config/sanitize.js ${{\color{Goldenrod}{ }}}$ 0.4%, 8.28 KB
(other) ${{\color{Goldenrod}{ ████████▏ }}}$ 32.9%, 649.93 KB

Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js

Path Size
../../node_modules ${{\color{Goldenrod}{ █████████████████████▉ }}}$ 87.7%, 475.32 KB
dist/fields/validations.js ${{\color{Goldenrod}{ ▍ }}}$ 1.9%, 10.30 KB
dist/fields/config ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 5.83 KB
dist/utilities/traverseFields.js ${{\color{Goldenrod}{ ▏ }}}$ 0.8%, 4.34 KB
dist/utilities/deepCopyObject.js ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 3.52 KB
dist/collections/config ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 3.46 KB
dist/config/orderable ${{\color{Goldenrod}{ ▏ }}}$ 0.6%, 3.13 KB
dist/fields/baseFields ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 2.79 KB
dist/config/client.js ${{\color{Goldenrod}{ ▏ }}}$ 0.5%, 2.62 KB
dist/utilities/getDateOnlyComparison.js ${{\color{Goldenrod}{ }}}$ 0.4%, 2.41 KB
dist/auth/cookies.js ${{\color{Goldenrod}{ }}}$ 0.3%, 1.55 KB
dist/utilities/flattenTopLevelFields.js ${{\color{Goldenrod}{ }}}$ 0.3%, 1.42 KB
dist/utilities/getVersionsConfig.js ${{\color{Goldenrod}{ }}}$ 0.2%, 1.04 KB
dist/globals/config ${{\color{Goldenrod}{ }}}$ 0.2%, 957 B
dist/utilities/unflatten.js ${{\color{Goldenrod}{ }}}$ 0.2%, 938 B
dist/uploads/generatePayloadFileURL.js ${{\color{Goldenrod}{ }}}$ 0.2%, 864 B
dist/auth/extractJWT.js ${{\color{Goldenrod}{ }}}$ 0.1%, 807 B
dist/utilities/flattenAllFields.js ${{\color{Goldenrod}{ }}}$ 0.1%, 798 B
dist/errors/ValidationError.js ${{\color{Goldenrod}{ }}}$ 0.1%, 772 B
dist/utilities/sanitizeUserDataForEmail.js ${{\color{Goldenrod}{ }}}$ 0.1%, 713 B
(other) ${{\color{Goldenrod}{ ███ }}}$ 12.3%, 66.93 KB

Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js

Path Size
dist/features/blocks ${{\color{Goldenrod}{ ███▌ }}}$ 14.2%, 42.45 KB
dist/lexical/plugins ${{\color{Goldenrod}{ ███ }}}$ 12.4%, 37.19 KB
dist/lexical/ui ${{\color{Goldenrod}{ ██▊ }}}$ 11.2%, 33.66 KB
dist/features/table ${{\color{Goldenrod}{ ██▎ }}}$ 9.3%, 27.80 KB
dist/features/toolbars ${{\color{Goldenrod}{ █▊ }}}$ 7.4%, 22.25 KB
dist/features/link ${{\color{Goldenrod}{ █▌ }}}$ 6.2%, 18.61 KB
dist/features/upload ${{\color{Goldenrod}{ █▏ }}}$ 4.7%, 14.03 KB
dist/features/textState ${{\color{Goldenrod}{ ▉ }}}$ 3.7%, 11.08 KB
dist/lexical/utils ${{\color{Goldenrod}{ ▊ }}}$ 3.3%, 10.01 KB
dist/features/relationship ${{\color{Goldenrod}{ ▊ }}}$ 3.1%, 9.32 KB
dist/features/converters ${{\color{Goldenrod}{ ▋ }}}$ 2.8%, 8.44 KB
dist/utilities/fieldsDrawer ${{\color{Goldenrod}{ ▋ }}}$ 2.8%, 8.31 KB
dist/features/debug ${{\color{Goldenrod}{ ▋ }}}$ 2.5%, 7.40 KB
dist/lexical/config ${{\color{Goldenrod}{ ▍ }}}$ 1.7%, 5.14 KB
dist/features/indent ${{\color{Goldenrod}{ ▎ }}}$ 1.4%, 4.16 KB
dist/features/lists ${{\color{Goldenrod}{ ▎ }}}$ 1.2%, 3.67 KB
dist/lexical/LexicalEditor.js ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 3.33 KB
dist/features/horizontalRule ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 3.29 KB
dist/features/format ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 3.28 KB
dist/field/Field.js ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 3.06 KB
(other) ${{\color{Goldenrod}{ █████████████████████▍ }}}$ 85.8%, 256.85 KB

Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js

Path Size
../../node_modules ${{\color{Goldenrod}{ ███████▏ }}}$ 28.7%, 394.56 KB
dist/elements/Hierarchy ${{\color{Goldenrod}{ ▉ }}}$ 3.6%, 49.27 KB
dist/views/Version ${{\color{Goldenrod}{ ▌ }}}$ 2.2%, 30.52 KB
dist/elements/BulkUpload ${{\color{Goldenrod}{ ▌ }}}$ 2.2%, 29.90 KB
dist/elements/Table ${{\color{Goldenrod}{ ▌ }}}$ 2.1%, 29.56 KB
dist/forms/Form ${{\color{Goldenrod}{ ▍ }}}$ 1.7%, 24.03 KB
dist/views/Dashboard ${{\color{Goldenrod}{ ▍ }}}$ 1.7%, 23.77 KB
dist/views/HierarchyList ${{\color{Goldenrod}{ ▍ }}}$ 1.6%, 21.50 KB
dist/views/Edit ${{\color{Goldenrod}{ ▍ }}}$ 1.5%, 20.36 KB
dist/elements/WhereBuilder ${{\color{Goldenrod}{ ▎ }}}$ 1.3%, 18.54 KB
dist/providers/Auth ${{\color{Goldenrod}{ ▎ }}}$ 1.3%, 17.40 KB
dist/fields/Relationship ${{\color{Goldenrod}{ ▎ }}}$ 1.2%, 17.10 KB
dist/fields/Blocks ${{\color{Goldenrod}{ ▎ }}}$ 1.2%, 16.73 KB
dist/fields/Upload ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 15.41 KB
dist/elements/Popup ${{\color{Goldenrod}{ ▎ }}}$ 1.1%, 14.51 KB
dist/widgets/Activity ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 14.12 KB
dist/views/List ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 13.71 KB
dist/elements/ReactSelect ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 13.28 KB
dist/elements/PublishButton ${{\color{Goldenrod}{ ▏ }}}$ 0.9%, 12.16 KB
dist/elements/QueryPresets ${{\color{Goldenrod}{ ▏ }}}$ 0.9%, 12.09 KB
(other) ${{\color{Goldenrod}{ █████████████████▊ }}}$ 71.3%, 981.28 KB

Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js

Path Size
dist/graphics/Logo ${{\color{Goldenrod}{ ███████▍ }}}$ 29.9%, 5.61 KB
../../node_modules ${{\color{Goldenrod}{ ███▌ }}}$ 14.1%, 2.65 KB
dist/graphics/Icon ${{\color{Goldenrod}{ ██ }}}$ 8.1%, 1.51 KB
dist/utilities/formatDocTitle ${{\color{Goldenrod}{ █▊ }}}$ 7.0%, 1.32 KB
dist/providers/TableColumns ${{\color{Goldenrod}{ █▏ }}}$ 4.6%, 866 B
dist/utilities/getGlobalData.js ${{\color{Goldenrod}{ █ }}}$ 4.1%, 762 B
dist/utilities/api.js ${{\color{Goldenrod}{ █ }}}$ 4.0%, 756 B
dist/utilities/groupNavItems.js ${{\color{Goldenrod}{ █ }}}$ 4.0%, 745 B
dist/utilities/traverseForLocalizedFields.js ${{\color{Goldenrod}{ ▊ }}}$ 3.0%, 570 B
dist/elements/Translation ${{\color{Goldenrod}{ ▋ }}}$ 2.6%, 493 B
dist/forms/Form ${{\color{Goldenrod}{ ▋ }}}$ 2.5%, 474 B
dist/utilities/handleTakeOver.js ${{\color{Goldenrod}{ ▌ }}}$ 2.3%, 440 B
dist/elements/withMergedProps ${{\color{Goldenrod}{ ▍ }}}$ 1.8%, 339 B
dist/utilities/getNavGroups.js ${{\color{Goldenrod}{ ▍ }}}$ 1.8%, 338 B
dist/utilities/getVisibleEntities.js ${{\color{Goldenrod}{ ▍ }}}$ 1.8%, 329 B
dist/elements/WithServerSideProps ${{\color{Goldenrod}{ ▎ }}}$ 1.2%, 233 B
dist/layouts/Root ${{\color{Goldenrod}{ ▎ }}}$ 1.2%, 230 B
dist/utilities/handleGoBack.js ${{\color{Goldenrod}{ ▎ }}}$ 1.0%, 180 B
dist/fields/mergeFieldStyles.js ${{\color{Goldenrod}{ ▏ }}}$ 0.8%, 158 B
dist/utilities/handleBackToDashboard.js ${{\color{Goldenrod}{ ▏ }}}$ 0.8%, 152 B
(other) ${{\color{Goldenrod}{ █████████████████▌ }}}$ 70.1%, 13.16 KB
Details

Next to the size is how much the size has increased or decreased compared with the base branch of this PR.

  • ‼️: Size increased by 20% or more. Special attention should be given to this.
  • ⚠️: Size increased in acceptable range (lower than 20%).
  • ✅: No change or even downsized.
  • 🗑️: The out file is deleted: not found in base branch.
  • 🆕: The out file is newly found: will be added to base branch.

@DanRibbens
DanRibbens marked this pull request as ready for review November 10, 2026 18:00
@DanRibbens
DanRibbens marked this pull request as draft November 10, 2026 18:13
DanRibbens added a commit that referenced this pull request Nov 10, 2026
Written with AI

## Description

When a content branch merge fails, show which document and field need
fixing alongside the existing error message:

`Unique Doc / #4 / slug: Value must be unique`

Preserve collection/global, document ID, optional locale, and field-path
context through both streamed and HTTP merge failures. Keep the error
visible in the merge dialog so the user can close it, correct the
document, and retry.

Targets the branch behind #19284. Shared Zod validation, validation
acceptance rules, and Lexical/MCP tests are unchanged. Schema-message
localization and configured field-label resolution are deferred to
[PYLD-5204](https://linear.app/figma/issue/PYLD-5204/localize-shared-schema-validation-errors-using-the-request-language)
and draft #19486; they do not block this PR.

## Changes

- Retain structured write-time field errors and the available source
document context, avoiding incorrect attribution of nested-operation
errors.
- Render the configured collection/global label, document ID, optional
locale, and existing field path before the original error message. No
field-label resolution is added.
- Keep validation and write failures in the dialog, without reporting a
completed or empty merge. Unexpected private errors remain generic in
client responses.
- Exercise real uniqueness failures through integration tests and a
browser regression. Consolidate mocked endpoint error cases into
branching integration suites that run across the database matrix; retain
the focused stream-cancellation unit test. Remove the custom
editorial-validation fixture.

Uniqueness conflicts are still detected during the actual write; adding
preview-time uniqueness checks is separate work.

## Test Plan

All checks below ran without #19486:

- Merge endpoint cancellation unit test: 1 passed. The eight added
mocked endpoint cases are consolidated into integration coverage.
- Chromium merge-dialog component tests: 12 passed, including the exact
`Unique Doc / #4 / slug: Value must be unique` presentation.
- Merge write-error integration suite: 10 passed per adapter on MongoDB,
PostgreSQL, and SQLite (30 total), covering real uniqueness failures,
source/change IDs, locale preservation and request-language messages,
unexpected private errors with debug enabled, and nested-operation
attribution for HTTP and streaming responses. The suite uses `db: all`
for the CI adapter matrix.
- Branching REST integration suite: 13 passed per adapter on MongoDB,
PostgreSQL, and SQLite (39 total), including public access-error
messages and status codes.
- SQLite/Chromium e2e: the real uniqueness conflict displays
document/field context, remains dismissible, and leaves the pending
change available (1 passed). Used the repository’s `--no-turbo` Webpack
option because Turbopack cannot resolve dependencies linked outside this
isolated worktree.
- Core and UI TypeScript checks passed after building project references
in the original implementation. Consolidation follow-up: targeted lint,
formatting, and `git diff --check` passed. The broader
`test/branching/tsconfig.json` typecheck does not pass; checking the
unmodified PR head confirmed existing generated-type,
adapter-declaration, and missing-import errors, with the added fixtures
encountering the same generated-type constraint.
- Diff audit: 11 files; no changes to the shared entity-input-schema
validator, Lexical, MCP, branch preview validation, or branching test
config/shared fixtures.
- Local checks used Node 22.23.1; the repository declares Node
>=24.22.1. Other database variants were not rerun locally.

### Accessibility assessment

Assessed WCAG 2.2 A/AA error identification (3.3.1), correction guidance
(3.3.3), and status messages (4.1.3). Chromium component and
real-browser assertions verify document/field identification, the error
alert, correction guidance, and dismissal. The existing keyboard
controls and focus handling are unchanged. Exact screen-reader
announcements and manual visual/assistive-technology verification remain
unverified; no conformance claim.

This branch has not been deployed

No deployments
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.

1 participant