You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: resolve config labels before interpolating them into strings - #19209
Fixes every remaining place on 3.x where a config label (a locale record or label function) or another value that is not a string or number is interpolated into a string without being resolved first.
User-visible fixes:
Sort buttons in list column headers had aria-label="Sort by [object Object] Ascending" when the field label is a locale record. This is the remaining case from #19198.
Query preset bar: "New", "Edit" and "Delete" preset labels, plus the delete confirmation, rendered [object Object] when queryPresets.labels uses locale records.
Number hasMany min/max errors interpolated the whole array. They now name the offending number.
Config errors (DuplicateGlobal, InvalidFieldName, InvalidFieldRelationship, MissingFieldInputOptions, ReservedFieldName) and the cloud-storage / payload-cloud delete error logs fall back to the field name or slug when the label is not a plain string.
LinkEditor was passing i18n as interpolation variables to t().
Why?
The other two sites from #19198 were fixed in #18358 and #19116 (dashboard card) and #19154 (document drawer). This PR fixes the rest of the bug class at once instead of one report at a time.
How?
I temporarily tightened TFunction to only accept primitive interpolation values and ran tsc -b, then ran a TypeScript compiler-API audit for the cases the compiler can't see (any values and labels in template literals).
Each site now resolves the label with getTranslation, or falls back to the name or slug where there is no i18n instance.
The TFunction type is unchanged, because narrowing it would be a breaking change. The main port is #19208.
Tests:
Unit test for the hasMany number message.
e2e tests in the i18n suite for the sort button labels and the query preset bar. Both fail on current 3.x with [object Object].
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Walkthrough
Error and validation messages now use string-safe values. Admin sort and query-preset accessibility labels resolve localized labels, with added i18n configuration and end-to-end coverage.
Changes: Error and validation messages
Layer / File(s)
Summary
Fallback labels in error messages packages/payload-cloud/src/hooks/afterDelete.ts, packages/plugin-cloud-storage/src/hooks/afterDelete.ts, packages/payload/src/errors/*
Collection error messages fall back to the collection slug when the singular label is not a string. Field and global error messages use labels when they are strings and otherwise use field names or slugs.
Values in validation messages packages/payload/src/fields/validations.ts, packages/payload/src/fields/validations.spec.ts
Date validation stringifies invalid values. Number-bound errors use the parsed number, and a test checks the value passed to the maximum-bound translation.
Admin label translations
Layer / File(s)
Summary
Resolve labels for admin controls packages/ui/src/elements/SortColumn/index.tsx, packages/ui/src/elements/QueryPresets/QueryPresetBar/index.tsx, packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.tsx
Sort-button and query-preset labels resolve localized labels before translation. Two link-editor translation calls no longer pass i18n explicitly.
Query-preset configuration and coverage test/i18n/config.ts, test/i18n/e2e.spec.ts, test/i18n/payload-types.ts
The i18n test collection enables query presets and defines English and Spanish labels. End-to-end tests check sort and query-preset accessible names. Generated types include query-preset and widget shapes.
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check
Issue #19198 requires resolved labels for the dashboard card, sort buttons, and document drawer. The changed SortColumn code resolves the label with getTranslation(label || ..., i18n) for both dir…
Provide reviewable current-head evidence for the dashboard collection-card and document-drawer accessible names, or otherwise establish that both paths resolve locale-record labels.
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title is concise and accurately summarizes the main change: resolving configuration labels before string interpolation.
Out of Scope Changes check
The changes match the current PR intent. They resolve non-string labels in query presets, sort buttons, configuration errors, cloud-storage deletion logs, and the reported LinkEditor translation cal…
Description check
The pull request description directly matches the changeset. It explains fixes for non-string label interpolation, accessibility labels, query preset labels, validation errors, configuration errors, d…
Full details: Out of Scope Changes check
Explanation
The changes match the current PR intent. They resolve non-string labels in query presets, sort buttons, configuration errors, cloud-storage deletion logs, and the reported LinkEditor translation calls. The validation test, i18n tests, query-preset test configuration, and generated types support those changes. No unrelated change is established.
Full details: Description check
Explanation
The pull request description directly matches the changeset. It explains fixes for non-string label interpolation, accessibility labels, query preset labels, validation errors, configuration errors, delete logs, and LinkEditor translations.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 1 functions across 15 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Full details: Linked Issues check
Explanation
Issue #19198 requires resolved labels for the dashboard card, sort buttons, and document drawer. The changed SortColumn code resolves the label with getTranslation(label || ..., i18n) for both directions. The supplied PR evidence does not establish the current-head behavior of the dashboard card or document drawer. References to other pull requests are not sufficient evidence.
Resolution
Provide reviewable current-head evidence for the dashboard collection-card and document-drawer accessible names, or otherwise establish that both paths resolve locale-record labels.
Finishing Touches: 💡 1
📝 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
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
packages/payload-cloud/src/hooks/afterDelete.ts
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
packages/payload/src/errors/DuplicateGlobal.ts
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
packages/payload/src/errors/InvalidFieldName.ts
ESLint skipped: the matched ESLint configuration already failed (missing-dependency).
12 others
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.
…9208)
### What?
Fixes every remaining place where a config label (a locale record or
label function) or another non-primitive value is interpolated into a
string without being resolved first.
User-visible fixes:
- **Group by button** showed `Group by [object Object]` for fields
nested in a group or named tab, because `ReducedField.label` holds JSX
there. It now uses `plainTextLabel`. `reduceFieldsToOptions` also falls
back to the humanized field name for `label: false` fields, as
`combineFieldLabel` already does, so the button no longer reads `Group
by Meta > `.
- **Number `hasMany` min/max errors** interpolated the whole array
(`1,2,30 is greater than the max allowed value of 10`). They now name
the offending number.
- **Config errors** (`DuplicateGlobal`, `InvalidFieldName`,
`InvalidFieldRelationship`, `MissingFieldInputOptions`,
`ReservedFieldName`) and the **cloud-storage / payload-cloud delete
error logs** printed `[object Object]` or the source of a label
function. They now fall back to the field name or slug when the label is
not a plain string, which matches the existing pattern in
`saveVersion.ts`.
- `LinkEditor` was passing `i18n` as interpolation variables to `t()`.
### Why?
Follow-up to
[#19198](#19198),
[#17959](#17959) and
[#18358](#18358). These bugs
keep coming back one at a time because `TFunction` accepts `options?:
Record<string, any>`, and the runtime stringifies each value, so objects
become `[object Object]`.
### How?
- I found the sites by temporarily narrowing `TFunction` to primitive
values and running `tsc -b`, then running a TypeScript compiler-API
audit for what the compiler can't see: `any` values, labels in template
literals, and `aria-label`, `title`, `placeholder` and `alt` attributes
across all packages. The remaining hits are counts, filenames, document
titles and GraphQL type names.
- The `TFunction` type is unchanged. Narrowing it would stop correct
code from compiling (for example booleans or `Date` values, which the
runtime stringifies fine), which is a breaking change under the
[versioning
policy](https://github.com/payloadcms/payload/blob/main/docs/migration-guide/versioning.mdx).
Tests:
- Unit test for the `hasMany` number message.
- e2e tests for the Group by button with a nested field and with a
nested `label: false` field. The first fails on `main` with `Group by
[object Object]`.
- e2e test for the sort button labels with a locale-record field label.
3.x port: [#19209](#19209)
---------
Co-authored-by: German Jablonski <[email protected]>
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
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.
What?
Fixes every remaining place on 3.x where a config label (a locale record or label function) or another value that is not a string or number is interpolated into a string without being resolved first.
User-visible fixes:
aria-label="Sort by [object Object] Ascending"when the field label is a locale record. This is the remaining case from #19198.[object Object]whenqueryPresets.labelsuses locale records.hasManymin/max errors interpolated the whole array. They now name the offending number.DuplicateGlobal,InvalidFieldName,InvalidFieldRelationship,MissingFieldInputOptions,ReservedFieldName) and the cloud-storage / payload-cloud delete error logs fall back to the field name or slug when the label is not a plain string.LinkEditorwas passingi18nas interpolation variables tot().Why?
The other two sites from #19198 were fixed in #18358 and #19116 (dashboard card) and #19154 (document drawer). This PR fixes the rest of the bug class at once instead of one report at a time.
How?
TFunctionto only accept primitive interpolation values and rantsc -b, then ran a TypeScript compiler-API audit for the cases the compiler can't see (anyvalues and labels in template literals).getTranslation, or falls back to the name or slug where there is noi18ninstance.TFunctiontype is unchanged, because narrowing it would be a breaking change. Themainport is #19208.Tests:
hasManynumber message.i18nsuite for the sort button labels and the query preset bar. Both fail on current 3.x with[object Object].Fixes #19198