Humanizr/Humanizer · error · InvalidOperationException

Locale ' .headings' defines unsupported property ' '…

Error message

Locale '{localeCode}.headings' defines unsupported property '{property}'. Supported properties: full, short.

What it means

The headings mapping accepts exactly two property names: 'full' and 'short'. Any additional key is unsupported because the heading set has a fixed schema, and the generator enumerates mapping keys to reject unknown properties early rather than silently ignoring them.

Solutions

  1. Remove or rename the unsupported property so only 'full' and 'short' remain.
  2. If a narrower abbreviation is needed, place it under 'short:' and adjust the values.
  3. Double-check spelling: it must be exactly 'full' and 'short'.

Example fix

# before
headings:
  full:
    - January
  medium:
    - Jan

# after
headings:
  full:
    - January
  short:
    - Jan
Defensive patterns

Strategy: validation

Validate before calling

import yaml, pathlib
locales_dir = pathlib.Path('src/Humanizer/Locales')
allowed = {'full', 'short'}
for f in locales_dir.rglob('*.yml'):
    data = yaml.safe_load(f.read_text())
    if isinstance(data, dict) and isinstance(data.get('headings'), dict):
        extra = set(data['headings'].keys()) - allowed
        if extra:
            print(f'{f.name}: headings has unsupported keys: {extra}')

Prevention

When it happens

Trigger: A locale's 'headings:' mapping contains a key other than 'full' or 'short', such as 'medium', 'narrow', or a typo like 'ful'.

Common situations: Copy-pasting CLDR-style property names (narrow, medium) that this schema does not support; typos in property names; leftover experimental keys.

Related errors


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

Appendix: source

Thrown at src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs:792

        }

        static HeadingSet? ResolveHeadings(
            string localeCode,
            ImmutableDictionary<string, SimpleYamlValue> features)
        {
            if (!features.TryGetValue("headings", out var headingValue))
            {
                return null;
            }

            if (headingValue is not SimpleYamlMapping mapping)
            {
                throw new InvalidOperationException($"Locale '{localeCode}.headings' must be a mapping.");
            }

            foreach (var property in mapping.Values.Keys.Where(static property => property is not ("full" or "short")))
            {
                throw new InvalidOperationException(
                    $"Locale '{localeCode}.headings' defines unsupported property '{property}'. Supported properties: full, short.");
            }

            return new HeadingSet(
                ParseHeadingSequence(mapping, "full", localeCode),
                ParseHeadingSequence(mapping, "short", localeCode));
        }

        static SimpleYamlMapping? ResolveCalendar(
            string localeCode,
            ImmutableDictionary<string, SimpleYamlValue> features)
        {
            return !features.TryGetValue("calendar", out var calendarValue)
                ? null
                : calendarValue as SimpleYamlMapping
                ?? throw new InvalidOperationException($"Locale '{localeCode}.calendar' must be a mapping.");
        }

View on GitHub (pinned to ffc2b77c0f)