Humanizr/Humanizer · critical · InvalidOperationException
Locale '{localeCode}.surfaces.ordinal.date' must be a mappin
Error message
Locale '{localeCode}.surfaces.ordinal.date' must be a mapping, not a scalar or sequence. What it means
Thrown by AddOrdinalFeatures when surfaces.ordinal.date is present but is not a YAML mapping. The 'date' surface (dateToOrdinalWords) must be a mapping, so scalar/sequence values fail the build.
Source
Thrown at src/Humanizer.SourceGenerators/Common/CanonicalLocaleAuthoring.cs:427
$"Locale '{localeCode}.surfaces.ordinal' defines unsupported property '{property}'. Supported properties: numeric, date, dateOnly.");
}
if (ordinalSurface.TryGetValue("numeric", out var numericValue))
{
if (numericValue is not SimpleYamlMapping numericMapping)
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.ordinal.numeric' must be a mapping, not a scalar or sequence.");
}
features["ordinalizer"] = numericMapping;
}
if (ordinalSurface.TryGetValue("date", out var dateValue))
{
if (dateValue is not SimpleYamlMapping dateMapping)
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.ordinal.date' must be a mapping, not a scalar or sequence.");
}
features["dateToOrdinalWords"] = dateMapping;
}
if (ordinalSurface.TryGetValue("dateOnly", out var dateOnlyValue))
{
if (dateOnlyValue is not SimpleYamlMapping dateOnlyMapping)
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.ordinal.dateOnly' must be a mapping, not a scalar or sequence.");
}
features["dateOnlyToOrdinalWords"] = dateOnlyMapping;
}
}
View on GitHub (pinned to ffc2b77c0f)
Solutions
- Rewrite surfaces.ordinal.date as a mapping matching the dateToOrdinalWords rule shape.
- Copy the structure from a reference locale (e.g. en.yml) and translate values.
- Rebuild to confirm AddOrdinalFeatures accepts the surface.
Example fix
# before
ordinal:
date: on
# after
ordinal:
date:
1: first Defensive patterns
Strategy: validation
Validate before calling
# Ensure surfaces.ordinal.date is a mapping, not a scalar/sequence. # YAML lint: 'date:' must be followed by an indented mapping block.
Prevention
- Treat 'date' as a rule mapping (dateToOrdinalWords), not an enable flag.
- Mirror the structure from a reference locale.
- Build after edits to confirm AddOrdinalFeatures accepts it.
When it happens
Trigger: A locale YAML declares 'date: true' or 'date: [first, second]' under surfaces.ordinal. The type guard at CanonicalLocaleAuthoring.cs:425-429 fails because dateValue is not a SimpleYamlMapping.
Common situations: Treating 'date' as an enable flag; pasting a list of day ordinals; mis-indenting the block.
Related errors
- Locale '{localeCode}.surfaces.ordinal' defines unsupported p
- Locale '{localeCode}.surfaces.ordinal.numeric' must be a map
- Locale '{localeCode}.surfaces.ordinal.dateOnly' must be a ma
- Locale '{localeCode}.{path}' defines duplicate numeric minut
- Locale '{localeCode}.{path}.{key}' must be a string.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/b91854e1b2d5c610.
Report an issue: GitHub.