Humanizr/Humanizer · error · InvalidOperationException
'{path}.classification' has unsupported value '{unsupported}
Error message
'{path}.classification' has unsupported value '{unsupported}'. Supported values: distinct, invariant, not-applicable, unsupported. What it means
Thrown by ParseExplicit when the 'classification' scalar in an explicit (release-format) durationCases block has a value not in the set {distinct, invariant, not-applicable, unsupported}. The explicit parser uses 'invariant' (not 'same-as-nominative') as the label for locales where all cases share the nominative form. This is the explicit-format counterpart of error 52.
Source
Thrown at src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs:440
static DurationCaseCatalog ParseExplicit(
string localeCode,
SimpleYamlMapping mapping,
string path,
ImmutableArray<string> requiredMultipleForms)
{
RejectUnknownKeys(
mapping,
path,
["classification", "citationCase", "inventory", "sources", "cases", "reason", "provenance"]);
var classification = mapping.GetScalar("classification") switch
{
"distinct" => DurationCaseClassification.Distinct,
"invariant" => DurationCaseClassification.Invariant,
"not-applicable" => DurationCaseClassification.NotApplicable,
"unsupported" => DurationCaseClassification.Unsupported,
{ } unsupported => throw new InvalidOperationException(
$"'{path}.classification' has unsupported value '{unsupported}'. " +
"Supported values: distinct, invariant, not-applicable, unsupported."),
null => throw new InvalidOperationException($"'{path}' must define 'classification'.")
};
var sources = ParseSources(mapping, path);
if (classification == DurationCaseClassification.NotApplicable)
{
var reason = RequireScalar(mapping, "reason", path);
if (string.IsNullOrWhiteSpace(reason))
{
throw new InvalidOperationException($"'{path}.reason' must not be empty.");
}
ValidateProvenance(ParseProvenance(mapping, path, required: true), sources, path);
if (mapping.TryGetValue("inventory", out _) || mapping.TryGetValue("cases", out _))
{
throw new InvalidOperationException(View on GitHub (pinned to ffc2b77c0f)
Solutions
- Use 'invariant' instead of 'same-as-nominative' in explicit-format durationCases blocks.
- Verify the classification value is lowercase and matches exactly: distinct, invariant, not-applicable, or unsupported.
- If you need the legacy vocabulary ('same-as-nominative'), remove inventory/sources/provenance keys so ParseForTests routes to ParseLegacyForTests.
Example fix
# before (explicit format, legacy vocabulary) durationCases: classification: same-as-nominative inventory: [nominative] sources: [...] # after (explicit format, correct vocabulary) durationCases: classification: invariant inventory: [nominative] sources: [...]
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> ExplicitClassifications = new(StringComparer.Ordinal)
{ "distinct", "invariant", "not-applicable", "unsupported" };
static bool ExplicitClassificationIsValid(string? value) =>
value is not null && ExplicitClassifications.Contains(value); Prevention
- Explicit-format durationCases blocks use 'invariant', not 'same-as-nominative'.
- When converting from legacy to explicit format, update the classification vocabulary.
- Verify the classification value against the explicit set before adding inventory/sources keys.
When it happens
Trigger: ParseExplicit's switch expression catches any non-null classification value that doesn't match the four known labels via the { } unsupported pattern. For example 'classification: same-as-nominative' fails here because the explicit vocabulary uses 'invariant'. ParseExplicit is called when the durationCases block has inventory/sources/provenance/reason keys.
Common situations: A contributor copies a legacy-format durationCases block (using 'same-as-nominative') and adds inventory/sources keys to convert it to explicit format, but forgets to update the classification vocabulary. Or a typo/casing error is present.
Related errors
- '{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
- Locale '{locale.LocaleCode}' must classify the durationCases
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/fee3987c8b3f7e1c.
Report an issue: GitHub.