{"record":{"id":"a9ed79ba5cd63ee7","repo":"theonedev/onedev","slug":"project-criteria-is-not-supported-here","errorCode":null,"errorMessage":"Project criteria is not supported here","messagePattern":"Project criteria is not supported here","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/job/match/JobMatch.java","lineNumber":137,"sourceCode":"\t\t\t\tfor (JobMatchParser.CriteriaContext childCtx: ctx.criteria())\n\t\t\t\t\tchildCriterias.add(visit(childCtx));\n\t\t\t\treturn new AndCriteria<>(childCriterias);\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Criteria<io.onedev.server.job.match.JobMatchContext> visitNotCriteria(JobMatchParser.NotCriteriaContext ctx) {\n\t\t\t\treturn new NotCriteria<>(visit(ctx.criteria()));\n\t\t\t}\n\n\t\t}.visit(JobMatchContext.criteria());\n\t\t\n\t\treturn new JobMatch(criteria);\n\t}\n\t\n\tpublic static void checkField(String fieldName, boolean withProjectCriteria, boolean withJobCriteria) {\n\t\tif (fieldName.equals(Build.NAME_PROJECT)) {\n\t\t\tif (!withProjectCriteria)\n\t\t\t\tthrow new ExplicitException(\"Project criteria is not supported here\");\n\t\t} else if (fieldName.equals(Build.NAME_JOB)) {\n\t\t\tif (!withJobCriteria)\n\t\t\t\tthrow new ExplicitException(\"Job criteria is not supported here\");\n\t\t} else {\n\t\t\tthrow new ExplicitException(\"Invalid field: \" + fieldName);\n\t\t}\n\t}\n\n\t@Override\n\tpublic boolean matches(JobMatchContext context) {\n\t\treturn criteria.matches(context);\n\t}\n\n\t@Override\n\tpublic Predicate getPredicate(@Nullable ProjectScope projectScope, CriteriaQuery<?> query, From<JobMatchContext, JobMatchContext> from,\n\t\t\tCriteriaBuilder builder) {\n\t\tthrow new UnsupportedOperationException();\n\t}","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/match/JobMatch.java#L119-L155","documentation":"Thrown by JobMatch.checkField when a match expression uses the project field ('project is ...') in a context where project criteria are disallowed (withProjectCriteria=false), or generally when the field is invalid. The parse API's withProjectCriteria/withJobCriteria flags control which fields are legal.","triggerScenarios":"Calling JobMatch.parse(expression, false, ...) or an evaluation context whose parse flags exclude project criteria, while the expression contains 'project ...' criteria — e.g. in job secret authorization where project criteria are not permitted.","commonSituations":"Adding 'project is my-project' to a secret authorization expression; copy-pasting build-condition expressions (which allow project criteria) into secret authorization (which does not).","solutions":["Remove the project criteria from the expression","Use branch/commit criteria instead of project criteria in this context","If you control the call site, pass withProjectCriteria=true when project criteria should be legal","Split authorization per project rather than encoding project in one shared expression"],"exampleFix":"// before\nJobMatch.parse(\"project is my-app and on branch main\", false, false);\n// after\nJobMatch.parse(\"on branch main\", false, false);","handlingStrategy":"validation","validationCode":"// omit 'project ...' criteria where project criteria are disallowed\nJobMatch.parse(\"on branch main\", false, false); // ok\n// JobMatch.parse(\"project is x\", false, false); // would throw","typeGuard":null,"tryCatchPattern":"try {\n    var match = JobMatch.parse(expr, false, false);\n} catch (ExplicitException e) {\n    if (e.getMessage().contains(\"Project criteria is not supported\")) {\n        // strip project criteria and reparse\n    }\n}","preventionTips":["Do not use 'project ...' criteria in secret authorization expressions","Pass withProjectCriteria=true only when the context supports it","Scope secrets per project instead of encoding project in match expressions"],"tags":["ci","job-match","criteria","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}