Humanizr/Humanizer · error · InvalidOperationException

Locale '{localeCode}.{path}' must contain at most 60 entries

Error message

Locale '{localeCode}.{path}' must contain at most 60 entries for minute slots 0 through 59.

What it means

The dense (sequence) form of minuteWordsMap may have at most 60 entries, one per minute slot 0-59 (CanonicalLocaleAuthoring.cs:286-290). Extra entries have no minute to map to.

Source

Thrown at src/Humanizer.SourceGenerators/Common/CanonicalLocaleAuthoring.cs:288

                SimpleYamlSequence sequence => NormalizeMinuteWordsSequence(localeCode, path, sequence),
                SimpleYamlMapping mapping => NormalizeMinuteWordsMapping(localeCode, path, mapping),
                _ => throw new InvalidOperationException(
                    $"Locale '{localeCode}.{path}' must be a sequence or sparse numeric mapping.")
            };

            var normalizedClockSurface = clockSurface.Values.ToBuilder();
            normalizedClockSurface["minuteWordsMap"] = normalizedMinuteWordsMap;
            return new SimpleYamlMapping(normalizedClockSurface.ToImmutable());
        }

        static SimpleYamlMapping NormalizeMinuteWordsSequence(
            string localeCode,
            string path,
            SimpleYamlSequence sequence)
        {
            if (sequence.Items.Length > 60)
            {
                throw new InvalidOperationException(
                    $"Locale '{localeCode}.{path}' must contain at most 60 entries for minute slots 0 through 59.");
            }

            var normalizedValues = ImmutableDictionary.CreateBuilder<string, SimpleYamlValue>(StringComparer.Ordinal);
            for (var index = 0; index < sequence.Items.Length; index++)
            {
                ValidateMinuteWordValue(localeCode, path, index.ToString(CultureInfo.InvariantCulture), sequence.Items[index], allowEmpty: true);
                normalizedValues[index.ToString(CultureInfo.InvariantCulture)] = sequence.Items[index];
            }

            return new SimpleYamlMapping(normalizedValues.ToImmutable());
        }

        static SimpleYamlMapping NormalizeMinuteWordsMapping(
            string localeCode,
            string path,
            SimpleYamlMapping mapping)
        {

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Trim the sequence to at most 60 string entries.
  2. Prefer the sparse mapping form if you only need a handful of overrides.
  3. Rebuild.

Example fix

# before
surfaces:
  clock:
    minuteWordsMap: ["zero", ... 64 items ...]
# after
surfaces:
  clock:
    minuteWordsMap: ["zero", ... exactly <=60 items ...]
Defensive patterns

Strategy: validation

Validate before calling

import yaml, sys
doc = yaml.safe_load(open(sys.argv[1], encoding='utf-8'))
m = ((doc.get('surfaces') or {}).get('clock') or {}).get('minuteWordsMap')
if isinstance(m, list):
    assert len(m) <= 60, f'minuteWordsMap dense form has {len(m)} entries (max 60)'

Prevention

When it happens

Trigger: Pasting a list with 61+ items into minuteWordsMap.

Common situations: Including a label/heading line as the first element; appending extra values by mistake.

Related errors


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