Humanizr/Humanizer · error · InvalidOperationException

Indian scale-form number profiles require scales in descendi

Error message

Indian scale-form number profiles require scales in descending order.

What it means

Profile constructor validation: scale rows must be in strictly descending Value order. Equal or increasing adjacent values are rejected at instantiation.

Source

Thrown at src/Humanizer/Localisation/NumberToWords/IndianScaleFormNumberToWordsConverter.cs:165

    }

    static IndianScaleForm[] ValidateScales(IndianScaleForm[] value, int denseUnitCount)
    {
        if (value.Length == 0 || value[^1].Value > denseUnitCount)
        {
            throw new InvalidOperationException("Indian scale-form number profiles require a scale value covered by the dense unit map range.");
        }

        for (var i = 0; i < value.Length; i++)
        {
            if (value[i].Value <= 0)
            {
                throw new InvalidOperationException("Indian scale-form number profiles require positive scale values.");
            }

            if (i > 0 && value[i - 1].Value <= value[i].Value)
            {
                throw new InvalidOperationException("Indian scale-form number profiles require scales in descending order.");
            }
        }

        return value;
    }
}

/// <summary>
/// Describes one scale row with exact and continuing forms.
/// </summary>
/// <param name="Value">The numeric scale value.</param>
/// <param name="Singular">The singular scale form used when the phrase ends at this scale.</param>
/// <param name="SingularWithRemainder">The singular scale form used before a remainder.</param>
/// <param name="Plural">The plural scale form used when the phrase ends at this scale.</param>
/// <param name="PluralWithRemainder">The plural scale form used before a remainder.</param>
/// <param name="OmitOne">Whether a count of one is omitted before the singular scale form.</param>
readonly record struct IndianScaleForm(
    long Value,

View on GitHub (pinned to ffc2b77c0f)

Solutions

  1. Report the locale bug — scales are not strictly descending.
  2. Use a locale with correctly ordered scales.
  3. If authoring, order scale rows by descending Value with no duplicates.
Defensive patterns

Strategy: try-catch

Validate before calling

// Construction-time validation; no public pre-check. Isolate converter resolution per culture.

Try / catch

string words;
try
{
    words = value.ToWords(culture);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("scales in descending order"))
{
    words = value.ToWords(CultureInfo.InvariantCulture);
}

Prevention

When it happens

Trigger: First converter use for an IndianScaleForm culture whose scales are not strictly descending (value[i-1].Value <= value[i].Value for some adjacent pair).

Common situations: Locale YAML listing scales in the wrong order, or duplicate scale values.

Related errors


AI-assisted analysis of Humanizr/Humanizer@ffc2b77c0f (2026-08-13). Data as JSON: /api/errors/a492f7570fb9d46f. Report an issue: GitHub.