{"record":{"id":"366a746e7ee6a154","repo":"theonedev/onedev","slug":"job-criteria-is-not-supported-here","errorCode":null,"errorMessage":"Job criteria is not supported here","messagePattern":"Job 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":140,"sourceCode":"\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}\n\t\t\n\t@Override\n\tpublic void onMoveProject(String oldPath, String newPath) {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/match/JobMatch.java#L122-L158","documentation":"JobMatch.checkField validates that a criteria field name used in a job query is either 'Project' or 'Job'. The 'Job criteria is not supported here' ExplicitException is thrown when a query references the Job field but the caller explicitly disallowed job criteria (withJobCriteria=false), meaning job-name filtering is not valid in that query context.","triggerScenarios":"Calling a criteria-parsing/validation path (via visitFieldOperatorValueCriteria) that passes withJobCriteria=false while the parsed criteria contains a 'Job' field operator/value clause.","commonSituations":"Writing a build/job query in a context where filtering by job name is not permitted, e.g. certain branch or pull request criteria editors, or copy-pasting a query containing 'Job' criteria into a field that only accepts project-scoped criteria.","solutions":["Remove the 'Job' criteria clause from the query, or move the query to a context that supports job criteria.","If this is a code change, pass withJobCriteria=true to JobMatch.checkField / the criteria parser for the calling context.","Use the 'Project' field instead if project-level filtering is what was intended."],"exampleFix":"// before\nJobMatch.checkField(Build.NAME_JOB, true, false);\n// after\nJobMatch.checkField(Build.NAME_JOB, true, true);","handlingStrategy":"validation","validationCode":"boolean jobAllowed = /* context allows job criteria */;\nif (query.contains(\"Job \") && !jobAllowed) throw new IllegalArgumentException(\"Job criteria not allowed here\");","typeGuard":"boolean isAllowedField(String f) { return f.equals(Build.NAME_PROJECT) || f.equals(Build.NAME_JOB); }","tryCatchPattern":"try { parseCriteria(query); } catch (ExplicitException e) { log.error(\"Invalid job criteria: {}\", e.getMessage()); }","preventionTips":["Only use Project/Job fields in job queries","Check the query-context flags before adding criteria","Reuse the query builder UI instead of hand-writing criteria"],"tags":["criteria","query-validation","onedev"],"backgroundTag":"unsupported-operation","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"}