Humanizr/Humanizer · error · InvalidOperationException
Locale '{localeCode}.inflection' must be a mapping.
Error message
Locale '{localeCode}.inflection' must be a mapping. What it means
The 'inflection' feature contains locale-specific inflection configuration as a keyed mapping. Because inflection rules are language-bound and must not cross language boundaries, the resolver also blocks cross-language inheritance; a non-mapping value is rejected outright.
Source
Thrown at src/Humanizer.SourceGenerators/Common/LocaleYamlCatalog.cs:828
static SimpleYamlMapping? ResolveNumberFormatting(
string localeCode,
ImmutableDictionary<string, SimpleYamlValue> features)
{
return !features.TryGetValue("numberFormatting", out var formattingValue)
? null
: formattingValue as SimpleYamlMapping
?? throw new InvalidOperationException($"Locale '{localeCode}.numberFormatting' must be a mapping.");
}
static SimpleYamlMapping? ResolveInflection(
string localeCode,
ImmutableDictionary<string, SimpleYamlValue> features)
{
return !features.TryGetValue("inflection", out var inflectionValue)
? null
: inflectionValue as SimpleYamlMapping
?? throw new InvalidOperationException($"Locale '{localeCode}.inflection' must be a mapping.");
}
static ImmutableArray<string> ParseHeadingSequence(SimpleYamlMapping mapping, string key, string localeCode)
{
if (!mapping.TryGetValue(key, out var headingValue))
{
throw new InvalidOperationException($"Locale '{localeCode}.headings' must define '{key}'.");
}
if (headingValue is not SimpleYamlSequence sequence)
{
throw new InvalidOperationException($"Locale '{localeCode}.headings.{key}' must be a sequence.");
}
if (sequence.Items.Length != 16)
{
throw new InvalidOperationException($"Locale '{localeCode}.headings.{key}' must contain exactly 16 entries.");
}View on GitHub (pinned to ffc2b77c0f)
Solutions
- Ensure the 'inflection:' value is a mapping with the expected inflection sub-keys.
- Remove the key if the locale has no inflection data.
- Verify that the locale does not inherit inflection from a different-language parent (the resolver nulls inherited inflection across language subtags).
Example fix
# before
inflection: german
# after
inflection:
rules:
plural: german Defensive patterns
Strategy: validation
Validate before calling
import yaml, pathlib
locales_dir = pathlib.Path('src/Humanizer/Locales')
for f in locales_dir.rglob('*.yml'):
data = yaml.safe_load(f.read_text())
if isinstance(data, dict) and 'inflection' in data:
if not isinstance(data['inflection'], dict):
print(f'{f.name}: inflection must be a mapping, got {type(data["inflection"]).__name__}') Prevention
- Structure inflection as a mapping of rule properties.
- Remember that inflection does not inherit across different language subtags — author it locally.
- Remove the key if the locale has no inflection data.
When it happens
Trigger: A locale file sets 'inflection:' to a scalar or sequence rather than a mapping of inflection properties.
Common situations: Misstructuring inflection data; indentation errors; leaving a placeholder scalar after partial editing.
Related errors
- Phrase section '{path}' must be a mapping.
- Phrase section '{path}' defines unsupported property '{key}'
- Feature '{featureName}' in locale '{localeCode}' must be a s
- Locale '{localeCode}.grammar' must be a mapping.
- Locale '{localeCode}.phrases' must be a mapping.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/ee50bd22190faec8.
Report an issue: GitHub.