Humanizr/Humanizer · error · ArgumentException
Input words cannot be empty.
Error message
Input words cannot be empty.
What it means
VigesimalCompoundWordsToNumberConverter.TryConvert throws this ArgumentException at line 30 for null, empty, or whitespace input. It sits in the Try overload, so both ToNumber and TryToNumber throw on empty phrases; the converter needs at least one token to apply the base-20 grammar.
Source
Thrown at src/Humanizer/Localisation/WordsToNumber/VigesimalCompoundWordsToNumberConverter.cs:30
{
if (!TryConvert(words, out var parsedValue, out var unrecognizedWord))
{
throw new ArgumentException($"Unrecognized number word: {unrecognizedWord}");
}
return parsedValue;
}
/// <inheritdoc />
public override bool TryConvert(string words, out long parsedValue) =>
TryConvert(words, out parsedValue, out _);
/// <inheritdoc />
public override bool TryConvert(string words, out long parsedValue, out string? unrecognizedWord)
{
if (string.IsNullOrWhiteSpace(words))
{
throw new ArgumentException("Input words cannot be empty.");
}
var normalized = TokenMapWordsToNumberNormalizer.Normalize(words, TokenMapNormalizationProfile.LowercaseReplacePeriodsWithSpaces);
var negative = false;
foreach (var negativePrefix in profile.NegativePrefixes)
{
if (!normalized.StartsWith(negativePrefix, StringComparison.Ordinal))
{
continue;
}
negative = true;
normalized = normalized[negativePrefix.Length..].Trim();
break;
}
if (profile.OrdinalMap.TryGetValue(normalized, out var value) ||View on GitHub (pinned to ffc2b77c0f)
Solutions
- Pre-check !string.IsNullOrWhiteSpace(words) before calling any number method.
- Handle blank as a caller-side condition (skip or reprompt).
- Normalize upstream so empty never reaches the converter.
Example fix
// before
input.TryToNumber(out var n, culture); // throws if input is null/whitespace
// after
if (!string.IsNullOrWhiteSpace(input) && input.TryToNumber(out var n, culture))
Use(n); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(words))
return Result.Skip();
var ok = words.TryToNumber(out var n, culture); Try / catch
try { var n = words.ToNumber(culture); }
catch (ArgumentException ex) when (ex.Message == "Input words cannot be empty.")
{ /* blank input */ } Prevention
- Guard IsNullOrWhiteSpace before number-word calls.
- Treat blank input as a caller condition.
- Normalize upstream so empty never reaches the converter.
When it happens
Trigger: Passing null, string.Empty, or whitespace to any number method on a vigesimal-compound locale. The IsNullOrWhiteSpace check at line 29 fires before normalization.
Common situations: Blank fields, trimmed-to-empty values, unvalidated external input, empty substitution for missing data.
Related errors
- Input words cannot be empty.
- Input words cannot be empty.
- Input words cannot be empty.
- Input words cannot be empty.
- Input words cannot be empty.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/3c2f4352256d45d0.
Report an issue: GitHub.