{"record":{"id":"723c4a0a7e0fc248","repo":"apache/skywalking","slug":"single-labeled-to-single-labeled-right-labeled-re","errorCode":null,"errorMessage":"Single Labeled to Single Labeled, right labeled result has more than one value.","messagePattern":"Single Labeled to Single Labeled, right labeled result has more than one value\\.","errorType":"exception","errorClass":"IllegalExpressionException","httpStatus":null,"severity":"error","filePath":"oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/LROp.java","lineNumber":142,"sourceCode":"    private static ExpressionResult single2SingleLabeled(ExpressionResult singleLeft,\n                                                           ExpressionResult singleRight,\n                                                           int opType, LROp calculate) throws IllegalExpressionException {\n        Map<Set<KeyValue>, List<MQEValue>> labelMapR = new HashMap<>();\n        singleRight.getResults().forEach(mqeValuesR -> {\n            labelMapR.put(new HashSet<>(mqeValuesR.getMetric().getLabels()), mqeValuesR.getValues());\n        });\n        for (MQEValues mqeValuesL : singleLeft.getResults()) {\n            if (mqeValuesL.getValues().size() != 1) {\n                throw new IllegalExpressionException(\"Single Labeled to Single Labeled, left labeled result is empty or has more than one value.\");\n            }\n            //reserve left metric info\n            MQEValue valueL = mqeValuesL.getValues().get(0);\n            List<MQEValue> mqeValuesR = labelMapR.get(new HashSet<>(mqeValuesL.getMetric().getLabels()));\n            if (mqeValuesR == null) {\n                valueL.setEmptyValue(true);\n            } else {\n                if (mqeValuesR.size() != 1) {\n                    throw new IllegalExpressionException(\"Single Labeled to Single Labeled, right labeled result has more than one value.\");\n                }\n                MQEValue valueR = mqeValuesR.get(0);\n                if (valueL.isEmptyValue() || valueR.isEmptyValue()) {\n                    valueL.setEmptyValue(true);\n                    continue;\n                }\n                double value = calculate.apply(valueL.getDoubleValue(), valueR.getDoubleValue(), opType);\n                valueL.setDoubleValue(value);\n            }\n        }\n\n        return singleLeft;\n    }\n\n    //series or list or labeled single value with scalar\n    private static ExpressionResult many2OneBinaryOp(ExpressionResult manyResult,\n                                                     ExpressionResult singleResult,\n                                                     int opType, LROp calculate) throws IllegalExpressionException {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/LROp.java#L124-L160","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Query the right operand alone and check that every label group matching a left label has exactly one value","Tighten the relabels rules on the right side so each label combination maps to a single value","Aggregate the right operand (sum/avg/latest) before applying labels","Drop extra labels on the right side so groups do not fold multiple values together"],"exampleFix":"// before\nquery: relabels(sum(a), tag:(k,v)) + relabels(b, tag:(k,v))  // b has 2 values for (k,v)\n// after\nquery: relabels(sum(a), tag:(k,v)) + relabels(sum(b), tag:(k,v))","handlingStrategy":"validation","validationCode":"Map<Set<KeyValue>, Integer> sizes = right.getResults().stream()\n    .collect(toMap(g -> new HashSet<>(g.getMetric().getLabels()), g -> g.getValues().size()));\nboolean ok = sizes.values().stream().allMatch(s -> s == 1);","typeGuard":null,"tryCatchPattern":"catch (IllegalExpressionException e) { surfaceQueryError(e); }","preventionTips":["Ensure each right-side label combination resolves to a single value","Sum/aggregate the right operand before labeling it"],"tags":["mqe","query-engine","labels","binary-op"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}