Humanizr/Humanizer · error · InvalidOperationException

Locale coverage requires at least one canonical locale.

Error message

Locale coverage requires at least one canonical locale.

What it means

Thrown by LocaleCoverageInput.Create when the resolved locale catalog contains zero canonical locales. The coverage table needs at least one locale row to be meaningful, so an empty catalog is treated as a configuration failure rather than emitting an empty report.

Source

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

        ];

        public ImmutableArray<LocaleCoverageCapability> Capabilities { get; } = capabilities;
        public ImmutableArray<LocaleCoverageRow> Locales { get; } = locales;

        public static LocaleCoverageInput Create(LocaleCatalogInput catalog)
        {
            if (!catalog.Diagnostics.IsEmpty)
            {
                throw new InvalidOperationException(
                    string.Join(
                        "\n",
                        catalog.Diagnostics
                            .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)

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Confirm src/Humanizer/Locales contains the expected canonical locale .yml files (e.g. en.yml, fr.yml).
  2. If files were moved, restore them or update the discovery path the catalog uses.
  3. Ensure at least one locale file is recognized as canonical (correct filename and locale code).
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the Locales directory is populated:
#   ls src/Humanizer/Locales/*.yml | wc -l
# Must be >= 1 canonical locale file (e.g. en.yml).

Prevention

When it happens

Trigger: The locale catalog resolved to no canonical locale entries. This happens when no locale YAML files are present, all were filtered out as non-canonical, or the catalog construction mis-scanned the Locales directory.

Common situations: The src/Humanizer/Locales directory is empty or all .yml files were removed/mis-named, or a directory restructuring broke the glob the generator uses to discover locales. Surfaces as a build-time generator failure.

Related errors


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