fix(core): preserve locale casing in API locale filter (#1551)#1572
Open
marcusbellamyshaw-cell wants to merge 1 commit into
Open
fix(core): preserve locale casing in API locale filter (#1551)#1572marcusbellamyshaw-cell wants to merge 1 commit into
marcusbellamyshaw-cell wants to merge 1 commit into
Conversation
The `localeCode` validator lowercased the `?locale=` filter and create-body locale, but config `locales`/`defaultLocale`, the stored `locale` column, and the public query path all keep the raw BCP-47 casing. As a result the content and search APIs returned zero rows for any locale with an uppercase region or script subtag (e.g. zh-TW, pt-BR, zh-Hant). Drop the `.toLowerCase()` transform so the value is preserved verbatim; validation stays case-insensitive. This also matches the sibling `localeFilterQuery` (taxonomies/menus), which never lowercased. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 03525a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
What does this PR do?
Fixes the content and search APIs returning zero results when filtering by a locale with an uppercase region or script subtag (e.g.
?locale=zh-TW,pt-BR,zh-Hant).The
localeCodevalidator applied.transform(v => v.toLowerCase()), but configlocales/defaultLocale, the storedlocalecolumn, and the public query path all preserve the original BCP-47 casing. SQLite/D1 string comparison is case-sensitive, so the lowercased filter matched nothing. The siblinglocaleFilterQuery(taxonomies/menus) never lowercased, so this was also an internal inconsistency.Fix: drop the transform so the value is preserved verbatim. Validation stays case-insensitive (the
/iregex is unchanged).Closes #1551.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
New
localeCode validator (#1551)describe inpackages/core/tests/unit/api/schemas.test.ts: preserveszh-TW/pt-BR/zh-Hant, still validates case-insensitively, rejects malformed codes, and verifiescontentListQuery/contentCreateBodykeep the casing.