apache/skywalking · error · IllegalExpressionException

Unsupported function.

Error message

Unsupported function.

What it means

LogicalFunctionOp.doOP dispatches on the parsed operator token: only VIEW_AS_SEQ and IS_PRESENT are supported. Any other token reaching the switch falls through to 'Unsupported function.' as an IllegalExpressionException. In practice the ANTLR grammar only routes those two tokens here, so this is a defensive guard against grammar/runtime drift or a new logical token added to the grammar without a runtime implementation.

Source

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

import org.apache.skywalking.oap.server.core.query.mqe.ExpressionResultType;
import org.apache.skywalking.oap.server.core.query.mqe.MQEValue;
import org.apache.skywalking.oap.server.core.query.mqe.MQEValues;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;

import java.util.Objects;

public class LogicalFunctionOp {

    public static ExpressionResult doOP(int opType, MQEParser.ExpressionListContext expressionListContext,
                                                       MQEParserBaseVisitor<ExpressionResult> visitor) throws IllegalExpressionException {
        switch (opType) {
            case MQEParser.VIEW_AS_SEQ:
                return viewAsSeq(expressionListContext, visitor);
            case MQEParser.IS_PRESENT:
                return isPresent(expressionListContext, visitor);
        }

        throw new IllegalExpressionException("Unsupported function.");
    }

    private static ExpressionResult viewAsSeq(MQEParser.ExpressionListContext expressionListContext,
                                              MQEParserBaseVisitor<ExpressionResult> visitor) {
        ExpressionResult firstResult = null;
        for (MQEParser.ExpressionContext expContext : expressionListContext.expression()) {
            final ExpressionResult result = visitor.visit(expContext);
            if (firstResult == null) {
                firstResult = result;
            }
            if (result == null || CollectionUtils.isEmpty(result.getResults())) {
                continue;
            }
            final boolean isNotEmptyValue = result.getResults().stream()
                .filter(s -> s != null && CollectionUtils.isNotEmpty(s.getValues()))
                .flatMap(s -> s.getValues().stream()).anyMatch(s -> !s.isEmptyValue());
            if (isNotEmptyValue) {
                return result;

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Check the MQE expression uses only viewAsSeq(...) or isPresent(...) as logical functions
  2. If you extended MQEParser with a new logical token, add its case to LogicalFunctionOp.doOP and rebuild mqe-rt
  3. Ensure mqe-grammar and mqe-rt artifacts come from the same OAP version (no mixed jars in oap-libs)
  4. Simplify the query to isolate which function token triggers the failure

Example fix

// before (custom grammar token without runtime support)
query: logicalNot(metric)
// after
query: isPresent(metric)
Defensive patterns

Strategy: try-catch

Validate before calling

// before evaluating, whitelist logical functions against the OAP's supported set
Set<String> supported = Set.of("viewAsSeq", "isPresent");

Try / catch

catch (IllegalExpressionException e) { if (e.getMessage().contains("Unsupported function")) { /* grammar/runtime skew or unsupported token */ } }

Prevention

When it happens

Trigger: Executing an MQE expression whose logical function token is neither viewAsSeq nor isPresent — typically after the MQE grammar (mqe-grammar) was extended with a new logical function but mqe-rt was not updated, or when a custom OAP build mixes grammar and runtime versions.

Common situations: Custom OAP forks adding grammar rules without runtime handlers; upgrading only part of the MQE modules (grammar jar newer than runtime jar); malformed generated visitor dispatching an unexpected token type.

Related errors


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