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
- Confirm src/Humanizer/Locales contains the expected canonical locale .yml files (e.g. en.yml, fr.yml).
- If files were moved, restore them or update the discovery path the catalog uses.
- 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
- Never empty or relocate src/Humanizer/Locales without updating the catalog discovery path.
- Ensure at least one locale file uses a canonical locale code in its filename.
- Run a catalog test after directory restructuring.
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
- {diagnosticMessages}
- Locale '{locale.LocaleCode}' does not resolve required capab
- Billion-word cardinal strategy requires a singular billion w
- Billion-word cardinal strategy requires a plural billion wor
- Property '{propertyName}' must be a string, array, or mappin
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/6b5e448c13752d18.
Report an issue: GitHub.