apache/skywalking · error · IllegalExpressionException

Bool Operation: The result of the left expression is not 1 o

Error message

Bool Operation: The result of the left expression is not 1 or 0.

What it means

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.

Source

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

        }

        if (!checkExpression(right)) {
            throw new IllegalExpressionException(
                "Bool Operation: The result of the right expression is not a compare result.");
        }

        try {
            return LROp.doLROp(left, right, opType, BoolOp::boolOp);
        } catch (IllegalExpressionException e) {
            throw new IllegalExpressionException("Unsupported bool operation: " + e.getMessage());
        }
    }

    //bool with bool
    private static double boolOp(double leftValue, double rightValue, int opType) throws IllegalExpressionException {
        // this should not happen, but just in case
        if (!checkBool(leftValue)) {
            throw new IllegalExpressionException("Bool Operation: The result of the left expression is not 1 or 0.");
        }
        if (!checkBool(rightValue)) {
            throw new IllegalExpressionException("Bool Operation: The result of the right expression is not 1 or 0.");
        }
        switch (opType) {
            case MQEParser.AND:
                if (leftValue == 1 && rightValue == 1) {
                    return 1;
                } else {
                    return 0;
                }
            case MQEParser.OR:
                if (leftValue == 1 || rightValue == 1) {
                    return 1;
                } else {
                    return 0;
                }
            default:

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Align OAP module versions — rebuild/deploy a consistent release (mixed jars in oap-libs is the classic cause)
  2. If running a fork, audit your CompareOp/scalarCompareOp to guarantee boolToInt normalization to 0/1
  3. Report upstream with the full MQE expression if it reproduces on a stock versioned install
  4. As a workaround, rewrite the boolean chain using a single comparison per leaf and avoid nested boolean arithmetic
Defensive patterns

Strategy: try-catch

Try / catch

catch (IllegalExpressionException e) { /* invariant break: verify OAP module versions are consistent, then report upstream */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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