{"record":{"id":"5e947cefb2648408","repo":"apache/skywalking","slug":"bool-operation-the-result-of-the-left-expression-5e947c","errorCode":null,"errorMessage":"Bool Operation: The result of the left expression is not 1 or 0.","messagePattern":"Bool Operation: The result of the left expression is not 1 or 0\\.","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":50,"sourceCode":"        }\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\n        if (!checkBool(leftValue)) {\n            throw new IllegalExpressionException(\"Bool Operation: The result of the left expression is not 1 or 0.\");\n        }\n        if (!checkBool(rightValue)) {\n            throw new IllegalExpressionException(\"Bool Operation: The result of the right expression is not 1 or 0.\");\n        }\n        switch (opType) {\n            case MQEParser.AND:\n                if (leftValue == 1 && rightValue == 1) {\n                    return 1;\n                } else {\n                    return 0;\n                }\n            case MQEParser.OR:\n                if (leftValue == 1 || rightValue == 1) {\n                    return 1;\n                } else {\n                    return 0;\n                }\n            default:","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/BoolOp.java#L32-L68","documentation":"IllegalExpressionException from BoolOp.boolOp (scalar level): the left value feeding a boolean AND/OR is not exactly 1 or 0 after int truncation. The code comments note this 'should not happen' because compare results are normalized to 1/0 — so in practice it signals internal invariant breakage or version drift rather than a normal user mistake.","triggerScenarios":"A scalar reaching boolOp with leftValue outside {0.0, 1.0} — possible when a non-boolean result sneaks past checkExpression (isBoolResult true but values not normalized), e.g. mixed OAP module versions or a custom fork violating the invariant.","commonSituations":"Version mismatch between mqe-rt and query modules; patched/forked OAP where a compare implementation returns raw values instead of 0/1; extremely rare NaN propagation through the arithmetic path.","solutions":["Align OAP module versions — rebuild/deploy a consistent release (mixed jars in oap-libs is the classic cause)","If running a fork, audit your CompareOp/scalarCompareOp to guarantee boolToInt normalization to 0/1","Report upstream with the full MQE expression if it reproduces on a stock versioned install","As a workaround, rewrite the boolean chain using a single comparison per leaf and avoid nested boolean arithmetic"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (IllegalExpressionException e) { /* invariant break: verify OAP module versions are consistent, then report upstream */ }","preventionTips":["Deploy one consistent OAP build (no mixed jars)","In forks, keep compare results normalized to 0/1","Guard NaN inputs before boolean logic"],"tags":["mqe","boolean","internal","invariant","version-mismatch"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}