localeCode schema lowercases the ?locale= filter, returning zero rows for locales with uppercase subtags
#1778
khoinguyenpham04
announced in
Roadmap
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This Roadmap discussion mirrors #1551:
localeCodeschema lowercases the?locale=filter, returning zero rows for locales with uppercase subtags.Use this discussion to upvote the roadmap item and discuss priority, use cases, and product feedback. Keep implementation tracking, reproduction details, and PR-specific feedback on the source issue.
bug,bot:working,bot:bugOriginal Issue
Description
Filtering content by a locale that has an uppercase subtag (like
zh-TWoren-US) returns nothing on SQLite/D1, even though the rows exist.My site's default locale is
zh-TW. The admin content list came up completely blank, while the public site rendered all the posts fine. The API was returning{"items":[],"total":0}but the DB clearly had the data.Tracked it down to
localeCodeinpackages/core/src/api/schemas/common.ts:That
.toLowerCase()rewrites?locale=zh-TWtozh-twbefore the query runs. But stored locales keep the configured casing — the column DEFAULT comes straight fromdefaultLocale(database/migrations/040_byline_i18n.ts:121) and the read fallback uses it raw (query.ts:513), so rows are stored aszh-TW. SQLite and D1 compare strings case-sensitively, soWHERE locale = 'zh-tw'matches zero rows. The public site dodges this because it never goes through the query-param schema.So the filter lowercases but storage doesn't — the two sides disagree on casing. Affects any locale with an uppercase subtag (
zh-TW,zh-Hant,en-US,pt-BR,fr-CA, ...).Steps to reproduce
defaultLocale: "zh-TW".locale = 'zh-TW').GET /_emdash/api/content/<collection>?locale=zh-TW→{"items":[],"total":0}.SELECT count(*) FROM ... WHERE locale = 'zh-TW'returns the real count, and the admin content list shows up blank.Environment
main, HEADcb1c689)Logs / error output
Beta Was this translation helpful? Give feedback.
All reactions