Humanizr/Humanizer · error · InvalidOperationException
'{path}.cases' defines unsupported non-nominative case '{cas
Error message
'{path}.cases' defines unsupported non-nominative case '{caseName}'. What it means
Thrown by ParseLegacyForTests when the 'cases' mapping defines a key that is either not in the supported Cases list (an unknown grammatical case) or is explicitly named 'nominative' (which is implicit and must not be authored). The supported case names are defined in the Cases array (genitive, dative, accusative, instrumental, etc.).
Source
Thrown at src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs:368
classification == DurationCaseClassification.Invariant
? ImmutableDictionary<string, DurationCaseOverlay>.Empty
.WithComparers(StringComparer.Ordinal)
.Add("nominative", CreateBaseDurationOverlay())
: ImmutableDictionary<string, DurationCaseOverlay>.Empty.WithComparers(StringComparer.Ordinal));
}
if (!mapping.TryGetValue("cases", out var casesValue))
{
throw new InvalidOperationException($"Distinct duration cases for '{localeCode}' must define 'cases'.");
}
var casesMapping = ExpectMapping(casesValue, $"{path}.cases");
var cases = ImmutableDictionary.CreateBuilder<string, DurationCaseOverlay>(StringComparer.Ordinal);
foreach (var caseName in casesMapping.Values.Keys
.OrderBy(static name => name, StringComparer.Ordinal)
.Where(caseName => !Cases.Contains(caseName, StringComparer.Ordinal) || caseName == "nominative"))
{
throw new InvalidOperationException(
$"'{path}.cases' defines unsupported non-nominative case '{caseName}'.");
}
foreach (var caseName in Cases
.Where(static caseName => caseName != "nominative")
.Where(casesMapping.Values.ContainsKey))
{
cases[caseName] = ParseCase(casesMapping.Values[caseName], $"{path}.cases.{caseName}");
}
if (cases.Count == 0)
{
throw new InvalidOperationException($"Distinct duration cases for '{localeCode}' must define at least one case.");
}
return new DurationCaseCatalog(
localeCode,
classification,View on GitHub (pinned to ffc2b77c0f)
Solutions
- Remove any 'nominative' key from the cases mapping — it is implicit and auto-generated.
- Replace unknown case names with one from the supported Cases list (see DurationCaseModels.cs:255 for the full list).
- If you need a case not in the list, propose adding it to the Cases array first.
Example fix
# before (explicit nominative + unknown case)
durationCases:
classification: distinct
cases:
nominative: { ... }
myCase: { ... }
# after (valid case names only, no nominative)
durationCases:
classification: distinct
cases:
genitive: { ... } Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> SupportedCases = new(StringComparer.Ordinal)
{ "nominative","genitive","dative","accusative","instrumental","prepositional",
"ablative","comitative","ergative","locative","oblique","partitive","vocative",
"elative","illative","sociative","terminative","translative","absolutive",
"additive","inessive","allative","adessive","essive","abessive","equative",
"directive","lative","benefactive","causal" };
static IEnumerable<string> FindInvalidCaseKeys(SimpleYamlMapping cases) =>
cases.Values.Keys.Where(k => k == "nominative" || !SupportedCases.Contains(k)); Prevention
- Never author a 'nominative' key in cases — it is implicit and auto-generated.
- Only use case names from the SupportedCases list.
- If you need a new case, add it to the Cases array in DurationCaseModels.cs first.
When it happens
Trigger: ParseLegacyForTests filters casesMapping.Values.Keys for entries where (!Cases.Contains(caseName) || caseName == 'nominative') and throws for each match. For example 'cases:\n nominative: ...' or 'cases:\n myCustomCase: ...' triggers it.
Common situations: A contributor adds a 'nominative' entry explicitly not knowing it's always implicit. Or they invent a case name not in the supported list. The nominative base overlay is auto-generated by CreateBaseDurationOverlay, so authoring it is redundant and rejected.
Related errors
- Distinct duration cases for '{localeCode}' must define at le
- '{path}.classification' has unsupported value '{unsupported}
- '{path}' must define 'classification'.
- '{path}.cases' is only valid when classification is 'distinc
- Distinct duration cases for '{localeCode}' must define 'case
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/ad324c556ac2bff4.
Report an issue: GitHub.