Humanizr/Humanizer · error · InvalidOperationException

Locale '{locale.LocaleCode}' does not resolve required capab

Error message

Locale '{locale.LocaleCode}' does not resolve required capability '{definition.Key}' from checked-in YAML.

What it means

Thrown by LocaleCoverageInput.Create when a locale fails to resolve a non-optional capability from checked-in YAML. The coverage generator requires every shipped locale to provide or inherit each mandatory capability (formatter, phrases, inflection, numberToWords, wordsToNumber, ordinalizer, dateToOrdinalWords, timeOnlyToClockNotation, headings, list); a gap means the locale is incompletely specified.

Source

Thrown at src/Humanizer.SourceGenerators/Common/LocaleCoverageInput.cs:66

                            .Select(static diagnostic => diagnostic.GetMessage())
                            .OrderBy(static message => message, StringComparer.Ordinal)));
            }
            if (catalog.Locales.IsEmpty)
            {
                throw new InvalidOperationException("Locale coverage requires at least one canonical locale.");
            }

            var rows = ImmutableArray.CreateBuilder<LocaleCoverageRow>(catalog.Locales.Length);
            foreach (var locale in catalog.Locales.OrderBy(static locale => locale.LocaleCode, StringComparer.Ordinal))
            {
                var coverage = ImmutableDictionary.CreateBuilder<string, LocaleCoverageStatus>(StringComparer.Ordinal);
                foreach (var definition in Definitions)
                {
                    var resolved = definition.IsResolved(locale);
                    if (!resolved && !definition.Optional)
                    {
                        throw new InvalidOperationException(
                            $"Locale '{locale.LocaleCode}' does not resolve required capability '{definition.Key}' from checked-in YAML.");
                    }

                    var contributes = definition.AuthoredFeatureNames.Any(locale.AuthoredFeatureNames.Contains);
                    LocaleCoverageStatus status;
                    if (contributes)
                    {
                        status = new LocaleCoverageStatus("own", null);
                    }
                    else if (resolved && locale.VariantOf is not null)
                    {
                        status = new LocaleCoverageStatus("via", locale.VariantOf);
                    }
                    else
                    {
                        status = new LocaleCoverageStatus(definition.Optional ? "platform" : "missing", null);
                    }
                    coverage[definition.Key] = status;
                }

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Read the message: it names the locale code and the missing capability key (e.g. 'phrases', 'formatter').
  2. Add the missing section to the locale YAML, or set variantOf to a parent locale that provides it.
  3. For new locales, ensure all required capabilities are present before enabling locale coverage.
Defensive patterns

Strategy: validation

Validate before calling

# For the locale named in the message, confirm each required capability
# section exists or is inherited via variantOf:
#   rg "^(formatter|phrases|inflection|numberToWords|wordsToNumber|ordinalizer|dateToOrdinalWords|dateOnlyToOrdinalWords|timeOnlyToClockNotation|headings|collectionFormatter):" src/Humanizer/Locales/<code>.yml

Prevention

When it happens

Trigger: A locale YAML is missing one of the required capability sections and does not inherit it from a parent via variantOf. For example, a locale defines formatter but no phrases, or its variantOf parent also lacks the capability.

Common situations: Adding a new locale that is not yet complete, or deleting a capability section from an existing locale. The error names the locale code and the missing capability key so the contributor knows exactly what to add.

Related errors


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