apache/skywalking · error · IllegalExpressionException

Single Labeled to Single Labeled, right labeled result has…

Error message

Single Labeled to Single Labeled, right labeled result has more than one value.

What it means

In LROp.single2SingleLabeled (both operands labeled SINGLE_VALUE), the right operand's label groups are indexed into a map keyed by the HashSet of labels. When a left label group finds a matching right group, that right group must contain exactly one MQEValue; otherwise this exception is thrown because the pairing is ambiguous.

Solutions

  1. Query the right operand alone and check that every label group matching a left label has exactly one value
  2. Tighten the relabels rules on the right side so each label combination maps to a single value
  3. Aggregate the right operand (sum/avg/latest) before applying labels
  4. Drop extra labels on the right side so groups do not fold multiple values together

Example fix

// before
query: relabels(sum(a), tag:(k,v)) + relabels(b, tag:(k,v))  // b has 2 values for (k,v)
// after
query: relabels(sum(a), tag:(k,v)) + relabels(sum(b), tag:(k,v))
Defensive patterns

Strategy: validation

Validate before calling

Map<Set<KeyValue>, Integer> sizes = right.getResults().stream()
    .collect(toMap(g -> new HashSet<>(g.getMetric().getLabels()), g -> g.getValues().size()));
boolean ok = sizes.values().stream().allMatch(s -> s == 1);

Try / catch

catch (IllegalExpressionException e) { surfaceQueryError(e); }

Prevention

When it happens

Trigger: Both sides of a binary op are labeled scalars and share at least one label combination whose RIGHT-side group contains 2+ values. Non-matching label groups do NOT throw — they set emptyValue on the left — so the error only fires on matched labels with multi-valued right groups.

Common situations: relabels collapsing multiple right-side series into one label group that then matches a left label; a labeled right metric whose OAL/MAL definition emits several values per label set after a config change; mixing a labeled scalar with a metric that still carries extra labels that were meant to be dropped.

Related errors


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

Appendix: source

Thrown at oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/LROp.java:142

    private static ExpressionResult single2SingleLabeled(ExpressionResult singleLeft,
                                                           ExpressionResult singleRight,
                                                           int opType, LROp calculate) throws IllegalExpressionException {
        Map<Set<KeyValue>, List<MQEValue>> labelMapR = new HashMap<>();
        singleRight.getResults().forEach(mqeValuesR -> {
            labelMapR.put(new HashSet<>(mqeValuesR.getMetric().getLabels()), mqeValuesR.getValues());
        });
        for (MQEValues mqeValuesL : singleLeft.getResults()) {
            if (mqeValuesL.getValues().size() != 1) {
                throw new IllegalExpressionException("Single Labeled to Single Labeled, left labeled result is empty or has more than one value.");
            }
            //reserve left metric info
            MQEValue valueL = mqeValuesL.getValues().get(0);
            List<MQEValue> mqeValuesR = labelMapR.get(new HashSet<>(mqeValuesL.getMetric().getLabels()));
            if (mqeValuesR == null) {
                valueL.setEmptyValue(true);
            } else {
                if (mqeValuesR.size() != 1) {
                    throw new IllegalExpressionException("Single Labeled to Single Labeled, right labeled result has more than one value.");
                }
                MQEValue valueR = mqeValuesR.get(0);
                if (valueL.isEmptyValue() || valueR.isEmptyValue()) {
                    valueL.setEmptyValue(true);
                    continue;
                }
                double value = calculate.apply(valueL.getDoubleValue(), valueR.getDoubleValue(), opType);
                valueL.setDoubleValue(value);
            }
        }

        return singleLeft;
    }

    //series or list or labeled single value with scalar
    private static ExpressionResult many2OneBinaryOp(ExpressionResult manyResult,
                                                     ExpressionResult singleResult,
                                                     int opType, LROp calculate) throws IllegalExpressionException {

View on GitHub (pinned to 102af09b4a)