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

  1. Add a 'months' sequence of exactly 12 strings alongside 'monthsGenitive'.
  2. Or remove 'monthsGenitive' if the locale has no distinct genitive forms.
  3. 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

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


AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13). Data as JSON: /api/errors/18e5d535c449d9d6. Report an issue: GitHub.