Humanizr/Humanizer · error · InvalidOperationException

' ' defines unsupported property ' '. Supported properties…

Error message

'{path}' defines unsupported property '{key}'. Supported properties: {string.Join(", ", supported)}.

What it means

RejectUnknownKeys (DurationCaseModels.cs:1202-1208) enforces a closed schema: each mapping may only contain keys from an allow-list (a case allows only 'units'; a unit allows 'sameAsNominative', 'unsupported', or phrase keys). Any unrecognised key — including a typo, or mixing sameAsNominative with an extra field — throws and names the offending key plus the supported set.

Solutions

  1. Remove the unsupported key named in the message.
  2. If the key was meant to carry data, rename it to a supported one for that node (case -> 'units'; unit -> 'sameAsNominative'/'unsupported'/phrase).
  3. Ensure mutually-exclusive flags (sameAsNominative vs unsupported vs phrase) appear alone.

Example fix

# before - typo + extra key
second:
  sameAsNominative: true
  pluralForm: 'sekundy'   # unsupported
# after
second:
  sameAsNominative: true
Defensive patterns

Strategy: validation

Validate before calling

# Closed-schema key check for duration-case nodes
$caseKeys  = @('units')
$unitFlags = @('sameAsNominative','unsupported')
function Test-Unknown($node, $allowed, $path) {
    foreach ($k in $node.Keys) { if ($k -notin $allowed) { throw "'$path' has unsupported key '$k' (allowed: $($allowed -join ', '))" } }
}
Test-Unknown $parsed.durationCases.cases.$case $caseKeys "$locale.cases.$case"
foreach ($u in $parsed.durationCases.cases.$case.units.GetEnumerator()) {
    Test-Unknown $u.Value $unitFlags "$locale.cases.$case.units.$($u.Key)"
}

Prevention

When it happens

Trigger: A case mapping contains a key other than 'units'; a unit mapping mixes 'sameAsNominative' with another key; a typo like 'suported:' or 'unitsMap:'.

Common situations: Leftover experimental keys; copy-paste merging two blocks; misspelled property names; combining mutually-exclusive flags.

Related errors


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

Appendix: source

Thrown at src/Humanizer.SourceGenerators/Common/DurationCaseModels.cs:1206

        static bool ContainsInheritanceMarker(SimpleYamlValue value) =>
            value switch
            {
                SimpleYamlScalar scalar => scalar.Value.Contains("↑↑↑", StringComparison.Ordinal),
                SimpleYamlMapping mapping => mapping.Values.Values.Any(ContainsInheritanceMarker),
                SimpleYamlSequence sequence => sequence.Items.Any(ContainsInheritanceMarker),
                _ => false
            };

        static SimpleYamlMapping ExpectMapping(SimpleYamlValue value, string path) =>
            value as SimpleYamlMapping
            ?? throw new InvalidOperationException($"'{path}' must be a mapping.");

        static void RejectUnknownKeys(SimpleYamlMapping mapping, string path, IReadOnlyCollection<string> supported)
        {
            foreach (var key in mapping.Values.Keys.Where(key => !supported.Contains(key)))
            {
                throw new InvalidOperationException(
                    $"'{path}' defines unsupported property '{key}'. Supported properties: {string.Join(", ", supported)}.");
            }
        }
    }
}

View on GitHub (pinned to ffc2b77c0f)