{"record":{"id":"5d6577b1dcf9223e","repo":"apache/skywalking","slug":"bool-operation-the-result-of-the-left-expression","errorCode":null,"errorMessage":"Bool Operation: The result of the left expression is not a compare result.","messagePattern":"Bool Operation: The result of the left expression is not a compare result\\.","errorType":"exception","errorClass":"IllegalExpressionException","httpStatus":null,"severity":"error","filePath":"oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/BoolOp.java","lineNumber":30,"sourceCode":" * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\npackage org.apache.skywalking.mqe.rt.operation;\n\nimport org.apache.skywalking.mqe.rt.exception.IllegalExpressionException;\nimport org.apache.skywalking.mqe.rt.grammar.MQEParser;\nimport org.apache.skywalking.oap.server.core.query.mqe.ExpressionResult;\n\npublic class BoolOp {\n    public static ExpressionResult doBoolOp(ExpressionResult left,\n                                            ExpressionResult right,\n                                            int opType) throws IllegalExpressionException {\n        if (!checkExpression(left)) {\n            throw new IllegalExpressionException(\n                \"Bool Operation: The result of the left expression is not a compare result.\");\n        }\n\n        if (!checkExpression(right)) {\n            throw new IllegalExpressionException(\n                \"Bool Operation: The result of the right expression is not a compare result.\");\n        }\n\n        try {\n            return LROp.doLROp(left, right, opType, BoolOp::boolOp);\n        } catch (IllegalExpressionException e) {\n            throw new IllegalExpressionException(\"Unsupported bool operation: \" + e.getMessage());\n        }\n    }\n\n    //bool with bool\n    private static double boolOp(double leftValue, double rightValue, int opType) throws IllegalExpressionException {\n        // this should not happen, but just in case","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/BoolOp.java#L12-L48","documentation":"IllegalExpressionException from BoolOp.doBoolOp: boolean connectors (&&, ||) in MQE operate on the results of comparison expressions, and the left operand's ExpressionResult.isBoolResult() is false — i.e. the left side is a plain metric value, not the outcome of a compare operation (>, >=, ==, etc.).","triggerScenarios":"An MQE expression like 'service_sla > 1000 && service_resp_time > 500' is fine, but 'service_sla && service_resp_time > 500' (left side never compared) triggers it: the left sub-result was not produced by CompareOp so it carries no boolean semantics.","commonSituations":"Forgetting the comparison on one side of a logical expression; using a boolean-typed metric name directly expecting truthiness; copying SQL/PromQL boolean-idioms into MQE where only explicit comparisons yield booleans.","solutions":["Wrap the left operand in an explicit comparison: metric > 0, metric >= threshold","Make every leaf of a && / || chain a compare expression ('a > b && c < d')","Check for accidental operator omission when concatenating conditions in generated dashboards"],"exampleFix":"# before\nservice_sla && service_resp_time > 500\n# after\nservice_sla > 0 && service_resp_time > 500","handlingStrategy":"validation","validationCode":"// every leaf of && / || must be a compare result\nboolean isBoolLeaf(ExpressionResult r) { return r.isBoolResult(); }","typeGuard":"boolean isCompareResult(org.apache.skywalking.oap.server.core.query.mqe.ExpressionResult r) {\n    return r.isBoolResult();\n}","tryCatchPattern":null,"preventionTips":["Write boolean chains as 'X <op> Y && X2 <op> Y2' — every leaf compared","Never use a raw metric as a boolean operand","Preview boolean expressions in the UI before saving"],"tags":["mqe","boolean","compare","query","expression"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}