Humanizr/Humanizer · error · InvalidOperationException

Inflection lexeme '{id}' countability '{countability}' is un

Error message

Inflection lexeme '{id}' countability '{countability}' is unsupported.

What it means

A lexeme's 'countability' must be one of the supported set: 'count', 'mass', 'collective', 'plural-only'. ParseLexemes throws for any value outside that set.

Source

Thrown at src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs:271

                    "id", "pos", "countability", "sense", "forms", "sources");
                var id = GetRequiredScalar(lexeme, "id", "Inflection lexeme must define id");
                if (!ids.Add(id))
                {
                    throw new InvalidOperationException($"Duplicate inflection lexeme id '{id}'.");
                }

                if (GetRequiredScalar(lexeme, "pos", $"Inflection lexeme '{id}' must define pos") != "noun")
                {
                    throw new InvalidOperationException($"Inflection lexeme '{id}' pos must be 'noun'.");
                }

                var countability = GetRequiredScalar(
                    lexeme,
                    "countability",
                    $"Inflection lexeme '{id}' must define countability");
                if (!Countabilities.Contains(countability))
                {
                    throw new InvalidOperationException(
                        $"Inflection lexeme '{id}' countability '{countability}' is unsupported.");
                }

                string? sense = null;
                if (lexeme.TryGetValue("sense", out var senseValue))
                {
                    if (senseValue is not SimpleYamlScalar senseScalar ||
                        string.IsNullOrWhiteSpace(senseScalar.Value))
                    {
                        throw new InvalidOperationException(
                            $"Inflection lexeme '{id}' sense must be a non-empty scalar.");
                    }

                    sense = senseScalar.Value;
                }

                ValidateSources(lexeme, sourceIds, $"Inflection lexeme '{id}'");
                var forms = GetRequiredMapping(lexeme, "forms", $"Inflection lexeme '{id}' must define forms");

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Use one of: count, mass, collective, plural-only

Example fix

# before
        countability: 'uncountable'
# after
        countability: 'mass'
Defensive patterns

Strategy: validation

Validate before calling

var allowed = new[] { "count", "mass", "collective", "plural-only" };
foreach (var lexeme in lexemes)
    if (!allowed.Contains(lexeme.Countability))
        Report($"{locale}: lexeme '{lexeme.Id}' countability '{lexeme.Countability}' unsupported.");

Type guard

static bool CountabilitySupported(string c) =>
    c is "count" or "mass" or "collective" or "plural-only";

Prevention

When it happens

Trigger: A lexeme sets 'countability:' to a value not in {count, mass, collective, plural-only}.

Common situations: Using a linguistic term not in the set (e.g. 'uncountable' instead of 'mass', or 'countable' instead of 'count'); a typo.

Related errors


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