Humanizr/Humanizer · error · InvalidOperationException
Prefixed tens prefix '{property.Name}' must map to an intege
Error message
Prefixed tens prefix '{property.Name}' must map to an integer base value. What it means
Thrown while building a PrefixedTensRule[] when the YAML node is a mapping but one of its values is not an integer. The builder maps each tens prefix to an integer base value; a non-numeric value cannot become the rule's base.
Source
Thrown at src/Humanizer.SourceGenerators/Common/GenerationHelpers.cs:1393
}
static string CreatePrefixedTensRuleArrayExpression(JsonElement arrayElement)
{
if (arrayElement.ValueKind is not (JsonValueKind.Array or JsonValueKind.Object))
{
throw new InvalidOperationException("Expected JSON array or mapping.");
}
var builder = new StringBuilder("new PrefixedTensRule[] { ");
var first = true;
if (arrayElement.ValueKind == JsonValueKind.Object)
{
foreach (var (Name, Value) in arrayElement.EnumerateObject()
.Select(static property =>
{
return property.Value.ValueKind != JsonValueKind.Number || !property.Value.TryGetInt64(out var value)
? throw new InvalidOperationException($"Prefixed tens prefix '{property.Name}' must map to an integer base value.")
: (property.Name, Value: value);
})
.OrderByDescending(static entry => entry.Name.Length)
.ThenBy(static entry => entry.Name, StringComparer.Ordinal))
{
if (!first)
{
builder.Append(", ");
}
builder.Append("new(");
builder.Append(QuoteLiteral(Name));
builder.Append(", ");
builder.Append(Value.ToString(CultureInfo.InvariantCulture));
builder.Append(')');
first = false;
}
}View on GitHub (pinned to ffc2b77c0f)
Solutions
- Set each prefixed-tens prefix's value to an unquoted integer: zwanzig: 20.
- Remove any string, boolean, or decimal values from the mapping.
- Rebuild; the generator names the first remaining offending prefix.
Example fix
# before prefixedTens: zwanzig: 'twenty' # after prefixedTens: zwanzig: 20
Defensive patterns
Strategy: validation
Validate before calling
# Every prefixed-tens prefix must map to an unquoted integer base: # rg -A10 "prefixedTens" src/Humanizer/Locales/<code>.yml # No value should be a quoted string or boolean.
Prevention
- Use unquoted integer base values for every prefixed-tens prefix.
- Do not reuse the prefix word as the value.
- Build locally so the generator names the first offending prefix.
When it happens
Trigger: A locale YAML defines the prefixed-tens section as a mapping where at least one entry's value is a string, boolean, or non-integer number. The Select lambda checks ValueKind and TryGetInt64 and throws, naming the offending prefix.
Common situations: A contributor adds a tens prefix but supplies a word as the value instead of the integer base (e.g. zwanzig: 'twenty'). The build error names the specific prefix that is wrong.
Related errors
- Billion-word cardinal strategy requires a singular billion w
- Billion-word cardinal strategy requires a plural billion wor
- Property '{propertyName}' must be a string, array, or mappin
- Property '{propertyName}' must be a mapping.
- Expected JSON array or mapping.
AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13).
Data as JSON: /api/errors/15c9f749dfd9bf99.
Report an issue: GitHub.