Humanizr/Humanizer · error · InvalidOperationException

Inflection display category 'one' is unreachable without qua

Error message

Inflection display category 'one' is unreachable without quantitySelector 'exact-numeric-singleton'.

What it means

For cardinal rules whose reachable categories do not include 'one' (e.g. 'Other'), authoring a 'one' display on a lexeme or rule without 'quantitySelector: exact-numeric-singleton' produces output that can never be selected. IsCategoryReachable returns false and ValidateQuantitySelector rejects the dead category.

Source

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

                {
                    throw new InvalidOperationException(
                        "Inflection quantitySelector 'exact-numeric-singleton' requires at least one lexeme with an authored 'one' display.");
                }

                if (rules.Any(static rule => rule.Display.ContainsKey("one")))
                {
                    throw new InvalidOperationException(
                        "Inflection quantitySelector 'exact-numeric-singleton' cannot select productive rule display.");
                }

                return;
            }

            if (!IsCategoryReachable(mapping, cardinalRule, "one") &&
                (hasOptedLexeme ||
                 rules.Any(static rule => rule.Display.ContainsKey("one"))))
            {
                throw new InvalidOperationException(
                    "Inflection display category 'one' is unreachable without quantitySelector 'exact-numeric-singleton'.");
            }
        }

        static bool IsCategoryReachable(
            SimpleYamlMapping mapping,
            string cardinalRule,
            string category)
        {
            if (ReachableCategories(cardinalRule).Contains(category, StringComparer.Ordinal))
            {
                return true;
            }

            return mapping.TryGetValue("regionalRules", out var regionalRulesValue) &&
                regionalRulesValue is SimpleYamlMapping regionalRules &&
                regionalRules.Values.Any(entry =>
                    entry.Value is SimpleYamlScalar rule &&

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Add 'quantitySelector: exact-numeric-singleton' (and satisfy its preconditions: capability 'display-by-category', cardinalRule 'Other', an authored lexeme 'one')
  2. Remove the 'one' display entries from lexemes and rules
  3. Add a 'regionalRules' entry whose cardinal rule reaches 'one'

Example fix

# before (cardinalRule 'Other', no selector, has display.one)
    cardinalRule: 'Other'
    capability: 'display-by-category'
# after
    cardinalRule: 'Other'
    capability: 'display-by-category'
    quantitySelector: 'exact-numeric-singleton'
Defensive patterns

Strategy: validation

Validate before calling

// 'one' is reachable only via cardinalRule/regionalRules or the selector:
bool reachable = IsCategoryReachable(m, cardinalRule, "one");
bool hasOne = lexemes.Any(l => l.Display.ContainsKey("one")) ||
              rules.Any(r => r.Display.ContainsKey("one"));
if (!reachable && hasOne && !selectorSet)
    Report($"{locale}: 'one' is unreachable; add quantitySelector or remove 'one' displays.");

Type guard

static bool OneIsJustified(bool reachable, bool hasOne, bool selectorSet) =>
    !hasOne || reachable || selectorSet;

Prevention

When it happens

Trigger: cardinalRule's reachable set excludes 'one', no 'regionalRules' entry reaches 'one', quantitySelector is absent, yet a lexeme or rule defines a 'one' display.

Common situations: Enabling a 'one' display form on a locale whose cardinalRule is 'Other' but forgetting the quantitySelector; refactoring cardinalRule away from a rule that reaches 'one' (e.g. 'EnglishLike') without revisiting display categories.

Related errors


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