Humanizr/Humanizer · error · InvalidOperationException
Inflection lexeme '{id}' sense must be a non-empty scalar.
Error message
Inflection lexeme '{id}' sense must be a non-empty scalar. What it means
The optional 'sense:' field disambiguates homographs; if present it must be a single non-empty, non-whitespace scalar string. ParseLexemes throws when 'sense:' is empty, whitespace-only, a sequence/mapping, or null.
Source
Thrown at src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/InflectionCatalogParsing.cs:281
}
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");
ValidateProperties(
forms,
$"Inflection lexeme '{id}' forms",
"singular", "dictionaryPlural", "dictionary-plural", "display");
var singular = ParseForm(forms, "singular", alternateName: null, id, ownerScripts, casing);
var dictionaryPlural = ParseForm(
forms,
"dictionaryPlural",
"dictionary-plural",
id,View on GitHub (pinned to ffc2b77c0f)
Solutions
- Provide a non-empty scalar for 'sense:'
- Remove the 'sense:' key entirely if no disambiguation is needed
Example fix
# before
sense: ''
# after
sense: 'the animal'
# (or remove the key) Defensive patterns
Strategy: validation
Validate before calling
foreach (var lexeme in lexemes)
if (lexeme.TryGetValue("sense", out var s) &&
(s is not SimpleYamlScalar sc || string.IsNullOrWhiteSpace(sc.Value)))
Report($"{locale}: lexeme '{lexeme.Id}' sense must be a non-empty scalar."); Type guard
static bool SenseValid(SimpleYamlMapping lexeme) =>
!lexeme.TryGetValue("sense", out var s) ||
(s is SimpleYamlScalar sc && !string.IsNullOrWhiteSpace(sc.Value)); Prevention
- Omit 'sense:' when not needed; never leave it as an empty placeholder
When it happens
Trigger: 'sense:' is an empty quoted string, whitespace-only, a list, or a bare 'sense:' that YAML parses as null.
Common situations: Leaving 'sense: ''' as a placeholder; writing 'sense:' with no value.
Related errors
- Inflection defines unsupported quantity selector; expected '
- Inflection quantitySelector 'exact-numeric-singleton' requir
- Inflection quantitySelector 'exact-numeric-singleton' cannot
- Inflection display category 'one' is unreachable without qua
- Active inflection bundle must define lexemes.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/9bcb70ff8e053886.
Report an issue: GitHub.