{"record":{"id":"600c580130bcf8a8","repo":"apache/skywalking","slug":"line","errorCode":null,"errorMessage":"line {}:{} {}","messagePattern":"line (.+?):(.+?) (.+?)","errorType":"exception","errorClass":"ParseCancellationException","httpStatus":null,"severity":"error","filePath":"oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/exception/ParseErrorListener.java","lineNumber":36,"sourceCode":"\npackage org.apache.skywalking.mqe.rt.exception;\n\nimport org.antlr.v4.runtime.misc.ParseCancellationException;\nimport org.antlr.v4.runtime.BaseErrorListener;\nimport org.antlr.v4.runtime.RecognitionException;\nimport org.antlr.v4.runtime.Recognizer;\n\npublic class ParseErrorListener extends BaseErrorListener {\n    @Override\n    public void syntaxError(Recognizer<?, ?> recognizer,\n                            Object offendingSymbol,\n                            int line,\n                            int charPositionInLine,\n                            String msg,\n                            RecognitionException e)\n        throws ParseCancellationException {\n\n        throw new ParseCancellationException(\"line \" + line + \":\" + charPositionInLine + \" \" + msg);\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":39,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/exception/ParseErrorListener.java#L18-L39","documentation":"ParseCancellationException produced by the ANTLR ParseErrorListener attached to the MQE parser. Any lexical or syntax error in an MQE (Metrics Query Expression) string aborts parsing immediately; the message embeds the offending line, column, and ANTLR's diagnosis. This is the user-facing syntax error for all MQE queries (GraphQL metricsExpression / queryType expressions).","triggerScenarios":"An MQE string passed to the OAP GraphQL API that violates the MQE grammar: unbalanced parentheses, wrong function names, missing quotes around durations, invalid labels, stray characters. Example: 'service_sla/service_resp_time' typos or 'sum(' without close.","commonSituations":"Hand-writing MQE expressions in the UI custom dashboard or API calls; migrating PromQL habits into MQE (different function set); escaping issues when the expression is embedded in JSON/GraphQL payloads; UI version sending newer MQE syntax than the OAP supports.","solutions":["Use the reported line:column — it marks the exact offending token; fix the construct at that position","Check the MQE grammar reference (docs/en/api/metrics-query-expression.md) for the function/duration/label syntax you used","Simplify: paste the expression into the UI's MQE editor which surfaces the same error inline, and rebuild it piece by piece","For JSON/GraphQL transport, verify quoting/escaping survived (inner double quotes must be escaped)"],"exampleFix":"# before\nmetricsExpression: sum(service_resp_time, pt5m)\n# after\nmetricsExpression: aggregate_labels(service_resp_time.sum(dt5m), SUM)","handlingStrategy":"validation","validationCode":"import org.apache.skywalking.mqe.rt.MQEVisitorBase; // or the parse entry your version exposes\n// Dry-run parse before sending to the server:\ntry {\n    org.apache.skywalking.oap.server.core.query.mqe.ExpressionResult r = MQEVisitorBase.parse(expression); // per API\n} catch (ParseCancellationException e) { /* syntax error: fix line:col */ }","typeGuard":null,"tryCatchPattern":"catch (ParseCancellationException e) {\n    // e.getMessage() = \"line L:C msg\" — surface to the user at the exact position\n    return badRequest(\"MQE syntax error: \" + e.getMessage());\n}","preventionTips":["Use the UI MQE editor preview before saving dashboards","Keep a curated snippet library of validated MQE expressions","Escape inner quotes correctly when embedding MQE in JSON/GraphQL"],"tags":["mqe","antlr","syntax-error","query","graphql"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}