payloadcms/payload · error · Error
Locales must be defined for locale columns
Error message
Locales must be defined for locale columns
What it means
Thrown by the SQLite columnToCodeConverter when converting an enum column that is locale-aware (has a 'locale' key) but no locales array was supplied to the converter. For a localized enum the set of allowed values must come from the configured locale codes, so an empty/undefined locales list makes codegen impossible.
Source
Thrown at packages/drizzle/src/sqlite/columnToCodeConverter.ts:28
}) => {
let columnBuilderFn: string = column.type
const columnBuilderArgsArray: string[] = []
let defaultStatement: null | string = null
switch (column.type) {
case 'boolean': {
columnBuilderFn = 'integer'
columnBuilderArgsArray.push("mode: 'boolean'")
break
}
case 'enum': {
let options: string[]
if ('locale' in column) {
if (!locales?.length) {
throw new Error('Locales must be defined for locale columns')
}
options = locales
} else {
options = column.options
}
columnBuilderFn = 'text'
columnBuilderArgsArray.push(`enum: [${options.map((locale) => `'${locale}'`).join(', ')}]`)
break
}
case 'geometry':
case 'jsonb': {
columnBuilderFn = 'text'
columnBuilderArgsArray.push("mode: 'json'")
break
}View on GitHub (pinned to 00c58b35c0)
Solutions
- Pass the full locales array (from payload.config.localization.localeCodes) into the converter invocation.
- If the column is no longer localized, migrate the DB so the column is not marked with 'locale'.
- Ensure localization is enabled in the payload config before running codegen.
Example fix
// before
columnToCodeConverter(column, { ... }) // locales omitted
// after
columnToCodeConverter(column, { locales: payload.config.localization.localeCodes, ... }) Defensive patterns
Strategy: validation
Validate before calling
function convertEnumColumn(column, locales) {
if ('locale' in column && (!locales || !locales.length)) {
throw new Error('Locales must be supplied for locale enum columns')
}
} Type guard
const isLocaleColumn = (c) => 'locale' in c
Prevention
- Always thread payload.config.localization.localeCodes into any codegen that may touch locale columns.
- Run codegen only against configs that have localization enabled.
When it happens
Trigger: Running the schema-to-code converter on a SQLite enum column marked as localized while the converter is invoked without a locales argument (or with an empty array).
Common situations: Programmatic schema introspection / codegen tooling that forgets to pass locales; disabling localization in config while legacy locale columns still exist in the DB.
Related errors
- Either collectionSlug or globalSlug must be provided
- Cannot provide both collectionSlug and globalSlug
- Localization is not enabled in payload config
- ${collectionSlug ? 'Collection' : 'Global'} not found: ${col
- Migration aborted: version__status column not found in ${ver
AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12).
Data as JSON: /api/errors/298568396738b92c.
Report an issue: GitHub.