{"record":{"id":"1a5b3ef36df48398","repo":"theonedev/onedev","slug":"unexpected-operator-ctx-operator-gettext","errorCode":null,"errorMessage":"Unexpected operator: \" + ctx.operator.getText()","messagePattern":"Unexpected operator: \" \\+ ctx\\.operator\\.getText\\(\\)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/job/match/JobMatch.java","lineNumber":102,"sourceCode":"\t\t\t\t\tif (fieldName.equals(Build.NAME_PROJECT))\n\t\t\t\t\t\tcriterias.add(new ProjectCriteria(fieldValue, operator));\n\t\t\t\t\telse\n\t\t\t\t\t\tcriterias.add(new JobCriteria(fieldValue, operator));\n\t\t\t\t}\n\t\t\t\treturn operator == IsNot? Criteria.andCriterias(criterias): Criteria.orCriterias(criterias);\n\t\t\t}\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic Criteria<io.onedev.server.job.match.JobMatchContext> visitOperatorValueCriteria(JobMatchParser.OperatorValueCriteriaContext ctx) {\n\t\t\t\tvar criterias = new ArrayList<Criteria<io.onedev.server.job.match.JobMatchContext>>();\n\t\t\t\tfor (var quoted: ctx.criteriaValue.Quoted()) {\n\t\t\t\t\tString fieldValue = getValue(quoted.getText());\n\t\t\t\t\tswitch (ctx.operator.getType()) {\n\t\t\t\t\t\tcase OnBranch:\n\t\t\t\t\t\t\tcriterias.add(new OnBranchCriteria(fieldValue));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new ExplicitException(\"Unexpected operator: \" + ctx.operator.getText());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn Criteria.orCriterias(criterias);\n\t\t\t}\n\t\t\t\n\t\t\t@Override\n\t\t\tpublic Criteria<io.onedev.server.job.match.JobMatchContext> visitOrCriteria(JobMatchParser.OrCriteriaContext ctx) {\n\t\t\t\tList<Criteria<io.onedev.server.job.match.JobMatchContext>> childCriterias = new ArrayList<>();\n\t\t\t\tfor (JobMatchParser.CriteriaContext childCtx: ctx.criteria())\n\t\t\t\t\tchildCriterias.add(visit(childCtx));\n\t\t\t\treturn new OrCriteria<>(childCriterias);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Criteria<io.onedev.server.job.match.JobMatchContext> visitAndCriteria(JobMatchParser.AndCriteriaContext ctx) {\n\t\t\t\tList<Criteria<io.onedev.server.job.match.JobMatchContext>> childCriterias = new ArrayList<>();\n\t\t\t\tfor (JobMatchParser.CriteriaContext childCtx: ctx.criteria())\n\t\t\t\t\tchildCriterias.add(visit(childCtx));","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/match/JobMatch.java#L84-L120","documentation":"Thrown by JobMatch's visitOperatorValueCriteria when a field value criteria uses an operator the grammar accepted but the visitor does not handle (only OnBranch is supported for value-form criteria in that branch of the visitor). Thrown as ExplicitException listing the unexpected operator text.","triggerScenarios":"A job match expression of the form 'field operator \"value\"' where operator is not OnBranch — e.g. 'commit is abc' or another operator not mapped in visitOperatorValueCriteria's switch.","commonSituations":"Writing a match expression using an operator valid elsewhere (e.g. in build queries) but unsupported in this job match position; grammar evolved faster than the visitor; hand-editing expressions without the UI validator.","solutions":["Use only supported operators for value criteria in this context (e.g. 'on branch \"main\"')","Rewrite the condition with an explicitly supported field/operator combination","Update OneDev if a newer version supports the desired operator","Restructure the expression so the unsupported operator applies to a criteria form that handles it"],"exampleFix":"// before\n// match: \"commit is abc123\"\n// after\n// match: \"on branch main\"","handlingStrategy":"validation","validationCode":"// restrict value-criteria expressions to supported operators, e.g.\n// \"on branch main\" instead of \"commit is abc\"","typeGuard":null,"tryCatchPattern":"try {\n    var match = JobMatch.parse(expr, false, false);\n} catch (ExplicitException e) {\n    if (e.getMessage().startsWith(\"Unexpected operator\")) {\n        // replace unsupported operator with a supported one\n    }\n}","preventionTips":["Use only operators documented for job match value criteria","Prefer explicit 'on branch ...' form","Re-validate expressions after OneDev upgrades"],"tags":["ci","job-match","unsupported-operator"],"backgroundTag":"unsupported-enum-value","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"}