Humanizr/Humanizer · error · InvalidOperationException
Inflection quantitySelector 'exact-numeric-singleton' requir
Error message
Inflection quantitySelector 'exact-numeric-singleton' requires at least one lexeme with an authored 'one' display.
What it means
When 'quantitySelector: exact-numeric-singleton' is active, the selector picks the 'one' display category, so at least one lexeme must author a 'display.one' form. ValidateQuantitySelector throws when the selector is set but no lexeme has an authored 'one' display, because the selector would have nothing to select.
Source
Thrown at src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs:179
? ExactNumericSingletonSelector
: throw new InvalidOperationException(
"Inflection defines unsupported quantity selector; expected 'exact-numeric-singleton'.");
}
static void ValidateQuantitySelector(
SimpleYamlMapping mapping,
string cardinalRule,
string? quantitySelector,
ImmutableArray<InflectionLexemeInput> lexemes,
ImmutableArray<InflectionRuleInput> rules)
{
var hasOptedLexeme = lexemes.Any(static lexeme =>
lexeme.Display.ContainsKey("one"));
if (quantitySelector is not null)
{
if (!hasOptedLexeme)
{
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'.");View on GitHub (pinned to ffc2b77c0f)
Solutions
- Add a 'display.one' block (preferred + accepted) to at least one lexeme
- Remove the quantitySelector if the locale's cardinal rule already reaches 'one' via its CLDR rule
Example fix
# before
display:
other:
preferred: 'cat'
accepted:
- 'cat'
# after
display:
one:
preferred: 'cat'
accepted:
- 'cat'
other:
preferred: 'cats'
accepted:
- 'cats' Defensive patterns
Strategy: validation
Validate before calling
// Given parsed lexemes and an active quantitySelector:
bool selectorSet = m.GetScalar("quantitySelector") == "exact-numeric-singleton";
bool anyOne = lexemes.Any(l => l.Forms.Display.ContainsKey("one"));
if (selectorSet && !anyOne)
Report($"{locale}: add a lexeme display.one or drop quantitySelector."); Type guard
static bool SelectorHasOneDisplay(
bool selectorSet, IEnumerable<Lexeme> lexemes) =>
!selectorSet || lexemes.Any(l => l.Display.ContainsKey("one")); Prevention
- When enabling the selector, immediately add display.one to the first lexeme
- Mirror the ExactNumericSingletonInflectionFixture shape
When it happens
Trigger: quantitySelector is set to 'exact-numeric-singleton' but every lexeme's 'forms.display' omits the 'one' category (only 'other' or other categories are present).
Common situations: Enabling the selector on a locale whose lexemes only declare 'other'; deleting the lexeme that was the sole provider of the 'one' display; forgetting to add the 'one:' block when enabling the selector.
Related errors
- Inflection defines unsupported quantity selector; expected '
- Inflection quantitySelector 'exact-numeric-singleton' cannot
- Inflection display category 'one' is unreachable without qua
- Active inflection bundle must define lexemes.
- Inflection lexemes must be mappings.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/fe553dd847f9dfcb.
Report an issue: GitHub.