apache/skywalking · error · IllegalExpressionException
Single Labeled to Single Labeled, left labeled result is emp
Error message
Single Labeled to Single Labeled, left labeled result is empty or has more than one value.
What it means
Thrown by LROp.single2SingleLabeled, which handles SINGLE_VALUE op SINGLE_VALUE where BOTH sides are labeled results. The left side is iterated per label-group (MQEValues), and each group must hold exactly one MQEValue. If any labeled group on the left has a value count != 1, the labeled scalar is malformed and the exception fires.
Source
Thrown at oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/LROp.java:133
if (left.isEmptyValue() || right.isEmptyValue()) {
mqeValue.setEmptyValue(true);
} else {
double value = calculate.apply(left.getDoubleValue(), right.getDoubleValue(), opType);
mqeValue.setDoubleValue(value);
}
return result;
}
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);
}View on GitHub (pinned to 102af09b4a)
Solutions
- Query the left operand alone and inspect each results[] element: every labeled group must have exactly one value
- Fix the relabels rules or the metric definition so each label combination yields a single value
- Aggregate before labeling: apply sum()/latest() first, then relabels, so each group is a scalar
- If multiple values per label are legitimate, redesign the query — single2SingleLabeled semantics require one value per label group
Example fix
// before query: relabels(a, tag:(key1,val1)) + relabels(b, tag:(key1,val1)) // after (aggregate first so each label group is a scalar) query: relabels(sum(a), tag:(key1,val1)) + relabels(sum(b), tag:(key1,val1))
Defensive patterns
Strategy: validation
Validate before calling
boolean ok = left.isLabeledResult()
&& left.getResults().stream().allMatch(g -> g.getValues().size() == 1); Type guard
boolean isLabeledScalar(ExpressionResult r) {
return r.getType() == ExpressionResultType.SINGLE_VALUE
&& r.isLabeledResult()
&& r.getResults().stream().allMatch(g -> g.getValues().size() == 1);
} Try / catch
catch (IllegalExpressionException e) { log.warn("MQE labeled scalar invalid: {}", e.getMessage()); } Prevention
- Aggregate before relabels so each label group is a scalar
- Keep relabels rules 1:1 to avoid folding multiple values into one label group
When it happens
Trigger: MQE expression like 'relabels(a, ...) + relabels(b, ...)' or two labeled metrics combined with a binary operator, where at least one left label-group contains 0 or 2+ values. Reached when both operands are SINGLE_VALUE and both isLabeledResult() is true (LROp.java:87-88).
Common situations: Using relabels/on labels on a scalar metric that returns multiple values per label combination; label cardinality mismatch after a relabels rule maps several source labels onto one target label group; a metric redefined in OAL/MAL so it now emits multiple values where one used to be guaranteed.
Related errors
- Single Labeled to Single Labeled, right labeled result has m
- Single to Single, left result is empty or has more than one
- Single to Single, right result is empty or has more than one
- Many to One, single result is empty or has more than one val
- One to Many, single result is empty or has more than one val
AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14).
Data as JSON: /api/errors/9dd23468195ef6af.
Report an issue: GitHub.