{"record":{"id":"318386c7b1c15cf9","repo":"theonedev/onedev","slug":"malformed-job-match","errorCode":null,"errorMessage":"Malformed job match","messagePattern":"Malformed job match","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/job/match/JobMatch.java","lineNumber":57,"sourceCode":"\t\n\tpublic JobMatch(Criteria<JobMatchContext> criteria) {\n\t\tthis.criteria = criteria;\n\t}\n\n\tpublic static String getValue(String token) {\n\t\treturn StringUtils.unescape(FenceAware.unfence(token));\n\t}\n\t\n\tpublic static JobMatch parse(String jobMatchString, boolean withProjectCriteria, boolean withJobCriteria) {\n\t\tCharStream is = CharStreams.fromString(jobMatchString); \n\t\tJobMatchLexer lexer = new JobMatchLexer(is);\n\t\tlexer.removeErrorListeners();\n\t\tlexer.addErrorListener(new BaseErrorListener() {\n\n\t\t\t@Override\n\t\t\tpublic void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,\n\t\t\t\t\tint charPositionInLine, String msg, RecognitionException e) {\n\t\t\t\tthrow new RuntimeException(\"Malformed job match\", e);\n\t\t\t}\n\t\t\t\n\t\t});\n\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\tJobMatchParser parser = new JobMatchParser(tokens);\n\t\tparser.removeErrorListeners();\n\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\tJobMatchParser.JobMatchContext JobMatchContext = parser.jobMatch();\n\n\t\tCriteria<io.onedev.server.job.match.JobMatchContext> criteria = new JobMatchBaseVisitor<Criteria<io.onedev.server.job.match.JobMatchContext>>() {\n\n\t\t\t@Override\n\t\t\tpublic Criteria<io.onedev.server.job.match.JobMatchContext> visitParensCriteria(JobMatchParser.ParensCriteriaContext ctx) {\n\t\t\t\treturn visit(ctx.criteria()).withParens(true);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Criteria<io.onedev.server.job.match.JobMatchContext> visitFieldOperatorValueCriteria(JobMatchParser.FieldOperatorValueCriteriaContext ctx) {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/match/JobMatch.java#L39-L75","documentation":"Thrown by JobMatch.parse when the ANTLR lexer/parser reports a syntax error while parsing a job match expression. Wrapped in a RuntimeException with the underlying RecognitionException attached, meaning the match string does not conform to the JobMatch grammar.","triggerScenarios":"Parsing an authorization/condition expression with invalid syntax — unbalanced parentheses, unknown keywords, missing operators, stray characters — via JobMatch.parse(expression, withProjectCriteria, withJobCriteria).","commonSituations":"Typo in match expression in a secret authorization field or build condition; quoting mistakes around values; copied expressions using unsupported syntax from other CI systems.","solutions":["Validate the match expression syntax against OneDev's job match grammar","Check for unbalanced parentheses, missing 'or'/'and' operators, and unquoted values","Rewrite the expression incrementally, testing in the UI's expression editor if available","See the server log's nested RecognitionException for the offending token/position"],"exampleFix":"// before\nJobMatch.parse(\"branch is main &&\", false, false); // trailing operator\n// after\nJobMatch.parse(\"branch is main\", false, false);","handlingStrategy":"validation","validationCode":"// validate expression syntax before use\ntry {\n    JobMatch.parse(expression, false, false);\n} catch (RuntimeException e) {\n    throw new IllegalArgumentException(\"Invalid job match expression: \" + expression, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    var match = JobMatch.parse(expr, false, false);\n} catch (RuntimeException e) {\n    // surface syntax error with offending position from cause\n}","preventionTips":["Author match expressions in the UI editor with live validation","Check parentheses and quoting before saving","Test expressions on a scratch branch first"],"tags":["ci","parsing","job-match","syntax"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}