Humanizr/Humanizer · critical · InvalidOperationException
Locale '{localeCode}.surfaces.calendar.monthsGenitive' requi
Error message
Locale '{localeCode}.surfaces.calendar.monthsGenitive' requires 'months' to also be present. What it means
Thrown by AddCalendarFeatures when surfaces.calendar.monthsGenitive is present but surfaces.calendar.months is not. Genitive month forms only make sense alongside nominative ones, so the schema enforces the pairing at build time.
Source
Thrown at src/Humanizer.SourceGenerators/Common/CanonicalLocaleAuthoring.cs:477
{
if (monthsValue is not SimpleYamlSequence monthsSeq || monthsSeq.Items.Length != 12)
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.calendar.months' must be a sequence of exactly 12 strings.");
}
if (monthsSeq.Items.Any(static item => item is not SimpleYamlScalar))
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.calendar.months' items must be scalar strings.");
}
}
if (calendarSurface.TryGetValue("monthsGenitive", out var monthsGenitiveValue))
{
if (!hasMonths)
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.calendar.monthsGenitive' requires 'months' to also be present.");
}
if (monthsGenitiveValue is not SimpleYamlSequence genitiveSeq || genitiveSeq.Items.Length != 12)
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.calendar.monthsGenitive' must be a sequence of exactly 12 strings.");
}
if (genitiveSeq.Items.Any(static item => item is not SimpleYamlScalar))
{
throw new InvalidOperationException(
$"Locale '{localeCode}.surfaces.calendar.monthsGenitive' items must be scalar strings.");
}
}
if (calendarSurface.TryGetValue("hijriMonths", out var hijriMonthsValue))
{View on GitHub (pinned to ffc2b77c0f)
Solutions
- Add a 'months' sequence of exactly 12 strings alongside 'monthsGenitive'.
- Or remove 'monthsGenitive' if the locale has no distinct genitive forms.
- Rebuild to confirm the pairing requirement is satisfied.
Example fix
# before calendar: monthsGenitive: [..., ..., ...] # after calendar: months: [Styczeń, Luty, Marzec, Kwiecień, Maj, Czerwiec, Lipiec, Sierpień, Wrzesień, Październik, Listopad, Grudzień] monthsGenitive: [Stycznia, Lutego, Marca, Kwietnia, Maja, Czerwca, Lipca, Sierpnia, Września, Października, Listopada, Grudnia]
Defensive patterns
Strategy: validation
Validate before calling
# If monthsGenitive is present, months must also be present.
# After parsing the calendar surface: if ($hasGenitive -and -not $hasMonths) { error } Prevention
- Always define 'months' whenever you define 'monthsGenitive'.
- If the locale has no distinct genitive forms, omit monthsGenitive entirely.
- Build after edits to catch the pairing violation.
When it happens
Trigger: A locale YAML defines monthsGenitive but omits months. AddCalendarFeatures records hasMonths at CanonicalLocaleAuthoring.cs:458 and, when monthsGenitive is found without it, throws at lines 474-479.
Common situations: Adding only the genitive list because the locale reuses a parent's nominative months; deleting 'months' during cleanup while leaving 'monthsGenitive'; partial migration from a locale that combined both.
Related errors
- Locale '{localeCode}.surfaces.calendar' defines unsupported
- Locale '{localeCode}.surfaces.calendar.months' must be a seq
- Locale '{localeCode}.surfaces.calendar.months' items must be
- Locale '{localeCode}.surfaces.calendar.monthsGenitive' must
- Locale '{localeCode}.surfaces.calendar.monthsGenitive' items
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/18e5d535c449d9d6.
Report an issue: GitHub.