Humanizr/Humanizer · error · InvalidOperationException
Scale-leading compound parser profiles require positive scal
Error message
Scale-leading compound parser profiles require positive scale values.
What it means
ScaleLeadingCompoundWordsToNumberProfile.ValidateScales throws this InvalidOperationException at line 436 when any scale value is zero or negative. The grammar multiplies counts by scale values, so non-positive scales are meaningless and rejected eagerly at profile construction. This is a locale-authoring/config defect surfaced during registry initialization.
Source
Thrown at src/Humanizer/Localisation/WordsToNumber/ScaleLeadingCompoundWordsToNumberConverter.cs:436
var maximum = 1;
foreach (var value in values)
{
maximum = Math.Max(maximum, Tokenize(value).Length);
}
return maximum;
}
static string[] Tokenize(string value) =>
value.Split(' ', StringSplitOptions.RemoveEmptyEntries);
static ScaleLeadingCompoundScale[] ValidateScales(ScaleLeadingCompoundScale[] value)
{
for (var i = 0; i < value.Length; i++)
{
if (value[i].Value <= 0)
{
throw new InvalidOperationException("Scale-leading compound parser profiles require positive scale values.");
}
if (i > 0)
{
var previous = (ulong)value[i - 1].Value;
var current = (ulong)value[i].Value;
if (previous <= current || previous % current != 0)
{
throw new InvalidOperationException("Scale-leading compound parser profiles require descending scales where each larger scale is divisible by the next smaller scale.");
}
}
}
return value;
}
}View on GitHub (pinned to ffc2b77c0f)
Solutions
- Ensure every scale value in the locale's scale ladder is a positive integer.
- Regenerate locale source and run the locale tests.
- Add an authoring test that constructs the profile and asserts no throw.
Example fix
// before (profile scales) Scales: [ 1000000, 0, 100 ] // 0 <= 0 -> throws // after Scales: [ 1000000, 1000, 100 ]
Defensive patterns
Strategy: validation
Validate before calling
// Authoring guard: no scale value may be <= 0. static bool ScalesPositive(long[] scales) => scales.All(s => s > 0);
Prevention
- Ensure every scale value is a positive integer in the locale data.
- Regenerate source and run locale tests after scale edits.
- Add a profile-construction unit test.
When it happens
Trigger: A locale scale ladder containing a 0 or negative value (typo, missing value, sign error in YAML). The throw occurs when the profile is constructed by the generator/registry, typically at first use of the culture.
Common situations: Adding a scale-leading locale with an incomplete scale entry; YAML parsing a missing number as 0; copy-paste leaving a placeholder; generator wiring bug.
Related errors
- Scale-leading compound parser profiles require descending sc
- Teen prefix cannot be empty.
- Decimal marker must not be empty.
- Unrecognized number word: {unrecognizedWord}
- Locale '{localeCode}' defines unsupported top-level property
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/fe3c31cb90b97584.
Report an issue: GitHub.