Humanizr/Humanizer · error · InvalidOperationException
'{path}.classification' has unsupported value '{unsupported}
Error message
'{path}.classification' has unsupported value '{unsupported}'. Supported values: distinct, same-as-nominative, not-applicable, unsupported. What it means
Thrown by ParseLegacyForTests when the 'classification' scalar in a legacy durationCases block has a value not in the set {distinct, same-as-nominative, not-applicable, unsupported}. The legacy parser uses 'same-as-nominative' (not 'invariant') as the label for locales where all cases share the nominative form.
Source
Thrown at src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs:329
{
var path = $"{localeCode}.durationCases";
return ParseLegacyForTests(localeCode, ExpectMapping(value, path), path);
}
static DurationCaseCatalog ParseLegacyForTests(
string localeCode,
SimpleYamlMapping mapping,
string path)
{
RejectUnknownKeys(mapping, path, ["classification", "cases"]);
var classification = mapping.GetScalar("classification") switch
{
"distinct" => DurationCaseClassification.Distinct,
"same-as-nominative" => DurationCaseClassification.Invariant,
"not-applicable" => DurationCaseClassification.NotApplicable,
"unsupported" => DurationCaseClassification.Unsupported,
{ } unsupported => throw new InvalidOperationException(
$"'{path}.classification' has unsupported value '{unsupported}'. " +
"Supported values: distinct, same-as-nominative, not-applicable, unsupported."),
null => throw new InvalidOperationException($"'{path}' must define 'classification'.")
};
if (classification != DurationCaseClassification.Distinct)
{
if (mapping.TryGetValue("cases", out _))
{
throw new InvalidOperationException(
$"'{path}.cases' is only valid when classification is 'distinct'.");
}
return new DurationCaseCatalog(
localeCode,
classification,
"nominative",
classification == DurationCaseClassification.Invariant ? ["nominative"] : [],View on GitHub (pinned to ffc2b77c0f)
Solutions
- Use 'same-as-nominative' instead of 'invariant' in legacy-format durationCases blocks.
- Double-check spelling and casing: the values are lowercase and hyphenated (e.g. 'not-applicable', not 'NotApplicable').
- If you want to use 'invariant', switch to the explicit format by adding inventory/sources/provenance keys so ParseForTests routes to ParseExplicit.
Example fix
# before (legacy format, wrong vocabulary) durationCases: classification: invariant # after (legacy format, correct vocabulary) durationCases: classification: same-as-nominative
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> LegacyClassifications = new(StringComparer.Ordinal)
{ "distinct", "same-as-nominative", "not-applicable", "unsupported" };
static bool LegacyClassificationIsValid(string? value) =>
value is not null && LegacyClassifications.Contains(value); Prevention
- Legacy durationCases blocks use 'same-as-nominative', not 'invariant'.
- Classification values are lowercase and hyphenated — check spelling and casing.
- Keep a reference of legacy vs explicit vocabulary nearby when editing locale files.
When it happens
Trigger: ParseLegacyForTests reads classification via a switch expression; the { } unsupported pattern catches any non-null string that doesn't match the four known values. For example 'classification: invariant' fails here because the legacy vocabulary uses 'same-as-nominative'.
Common situations: A contributor writes 'classification: invariant' (the explicit-format term) in a legacy-format durationCases block. Or a typo like 'classification: Distinct' (wrong casing) or 'classification: same-as-nom' is present. The legacy and explicit parsers use different vocabulary for the same concept.
Related errors
- '{path}' must define 'classification'.
- '{path}.cases' is only valid when classification is 'distinc
- Distinct duration cases for '{localeCode}' must define 'case
- '{path}.cases' defines unsupported non-nominative case '{cas
- Distinct duration cases for '{localeCode}' must define at le
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/83a48bc7e0358d8f.
Report an issue: GitHub.