Humanizr/Humanizer · critical · InvalidOperationException
Locale '{localeCode}.surfaces.ordinal.dateOnly' must be a ma
Error message
Locale '{localeCode}.surfaces.ordinal.dateOnly' must be a mapping, not a scalar or sequence. What it means
Thrown by AddOrdinalFeatures when surfaces.ordinal.dateOnly is present but is not a YAML mapping. The 'dateOnly' surface (dateOnlyToOrdinalWords) must be a mapping; scalar or sequence values are rejected at build time.
Source
Thrown at src/Humanizer.SourceGenerators/Common/CanonicalLocaleAuthoring.cs:438
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;
}
}
static void AddCalendarFeatures(
string localeCode,
SimpleYamlMapping calendarSurface,
ImmutableDictionary<string, SimpleYamlValue>.Builder features)
{
foreach (var property in calendarSurface.Values.Keys.Where(static property => property is not ("months" or "monthsGenitive" or "hijriMonths")))
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.calendar' defines unsupported property '{property}'. Supported properties: months, monthsGenitive, hijriMonths.");
}
View on GitHub (pinned to ffc2b77c0f)
Solutions
- Rewrite surfaces.ordinal.dateOnly as a mapping matching the dateOnlyToOrdinalWords rule shape.
- Mirror the structure of surfaces.ordinal.date from a reference locale and adjust for date-only semantics.
- Rebuild to confirm the ordinal surface validates.
Example fix
# before
ordinal:
dateOnly: true
# after
ordinal:
dateOnly:
1: first Defensive patterns
Strategy: validation
Validate before calling
# Ensure surfaces.ordinal.dateOnly is a mapping, not a scalar/sequence. # YAML lint: 'dateOnly:' must be followed by an indented mapping block.
Prevention
- Treat 'dateOnly' as a rule mapping (dateOnlyToOrdinalWords), not a boolean.
- Mirror surfaces.ordinal.date from a reference locale and adjust for date-only semantics.
- Build after edits to confirm the type guard passes.
When it happens
Trigger: A locale YAML writes 'dateOnly: true' or a list under surfaces.ordinal.dateOnly. The type guard at CanonicalLocaleAuthoring.cs:436-440 fails because dateOnlyValue is not a SimpleYamlMapping.
Common situations: Confusing dateOnly with a boolean enable flag; pasting an array; mis-indentation turning the mapping into a scalar.
Related errors
- Locale '{localeCode}.surfaces.ordinal' defines unsupported p
- Locale '{localeCode}.surfaces.ordinal.numeric' must be a map
- Locale '{localeCode}.surfaces.ordinal.date' must be a mappin
- 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/d9d86b03f6ddb7ae.
Report an issue: GitHub.