apache/skywalking · error · IllegalArgumentException

Illegal rank value {rank}, must be positive

Error message

Illegal rank value {rank}, must be positive

What it means

SumHistogramPercentileFunction validates each rank in PercentileArgument before merging. Percentile ranks must be positive integers (1-99 style values); a rank of 0 or a negative number is rejected immediately with this IllegalArgumentException, before any bucket/rank-set compatibility checks.

Source

Thrown at oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/sum/SumHistogramPercentileFunction.java:107

    @Setter
    @Column(name = RANKS, storageOnly = true)
    @BanyanDB.MeasureField
    private IntList ranks = new IntList(10);

    private boolean isCalculated = false;

    @Override
    public void accept(final MeterEntity entity, final PercentileArgument value) {
        if (summation.size() > 0) {
            if (!value.getBucketedValues().isCompatible(summation)) {
                throw new IllegalArgumentException(
                    "Incompatible BucketedValues [" + value + "] for current PercentileFunction[" + summation + "]");
            }
        }

        for (final int rank : value.getRanks()) {
            if (rank <= 0) {
                throw new IllegalArgumentException("Illegal rank value " + rank + ", must be positive");
            }
        }

        if (ranks.size() > 0) {
            if (ranks.size() != value.getRanks().length) {
                throw new IllegalArgumentException(
                    "Incompatible ranks size = [" + value.getRanks().length + "] for current PercentileFunction[" + ranks
                        .size() + "]");
            } else {
                for (final int rank : value.getRanks()) {
                    if (!ranks.include(rank)) {
                        throw new IllegalArgumentException(
                            "Rank " + rank + " doesn't exist in the previous ranks " + ranks);
                    }
                }
            }
        } else {
            for (final int rank : value.getRanks()) {

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Change all ranks in the percentile(...) expression to positive integers (e.g. percentile(50, 75, 90, 99))
  2. Fix the sending agent/meter SDK so it never emits 0 or negative ranks
  3. Validate the generated MAL YAML config before deployment (config dry-run)

Example fix

# before
percentile(0, 50, 99) -> sum_histogram_percentile
# after
percentile(50, 99) -> sum_histogram_percentile
Defensive patterns

Strategy: validation

Validate before calling

// validate ranks before sending/accepting
for (int rank : argument.getRanks()) {
    if (rank <= 0) {
        throw new IllegalArgumentException("Config error: rank " + rank + " must be positive — fix the MAL percentile expression");
    }
}

Try / catch

Catch IllegalArgumentException at the receiver boundary, reject the whole meter batch with a descriptive error back to the sender/agent config, and log the metric name — the config, not the data, is wrong.

Prevention

When it happens

Trigger: A MAL rule passes 0 or a negative number as a percentile rank: `percentile(0, 50, 75) -> sum_histogram_percentile`, or a meter sender (native SkyWalking meter protocol) transmits a ranks array containing 0/-1.

Common situations: Typo in an otel-rules/meter-analyzer-config percentile expression; an agent-side SDK misconfigured with rank 0; a templating bug that renders an empty rank as 0.

Related errors


AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14). Data as JSON: /api/errors/da13256f2c34c11d. Report an issue: GitHub.