theonedev/onedev · error · ExplicitException

Project criteria is not supported here

Error message

Project criteria is not supported here

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/job/match/JobMatch.java:137

				for (JobMatchParser.CriteriaContext childCtx: ctx.criteria())
					childCriterias.add(visit(childCtx));
				return new AndCriteria<>(childCriterias);
			}

			@Override
			public Criteria<io.onedev.server.job.match.JobMatchContext> visitNotCriteria(JobMatchParser.NotCriteriaContext ctx) {
				return new NotCriteria<>(visit(ctx.criteria()));
			}

		}.visit(JobMatchContext.criteria());
		
		return new JobMatch(criteria);
	}
	
	public static void checkField(String fieldName, boolean withProjectCriteria, boolean withJobCriteria) {
		if (fieldName.equals(Build.NAME_PROJECT)) {
			if (!withProjectCriteria)
				throw new ExplicitException("Project criteria is not supported here");
		} else if (fieldName.equals(Build.NAME_JOB)) {
			if (!withJobCriteria)
				throw new ExplicitException("Job criteria is not supported here");
		} else {
			throw new ExplicitException("Invalid field: " + fieldName);
		}
	}

	@Override
	public boolean matches(JobMatchContext context) {
		return criteria.matches(context);
	}

	@Override
	public Predicate getPredicate(@Nullable ProjectScope projectScope, CriteriaQuery<?> query, From<JobMatchContext, JobMatchContext> from,
			CriteriaBuilder builder) {
		throw new UnsupportedOperationException();
	}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Remove the project criteria from the expression
  2. Use branch/commit criteria instead of project criteria in this context
  3. If you control the call site, pass withProjectCriteria=true when project criteria should be legal
  4. Split authorization per project rather than encoding project in one shared expression

Example fix

// before
JobMatch.parse("project is my-app and on branch main", false, false);
// after
JobMatch.parse("on branch main", false, false);
Defensive patterns

Strategy: validation

Validate before calling

// omit 'project ...' criteria where project criteria are disallowed
JobMatch.parse("on branch main", false, false); // ok
// JobMatch.parse("project is x", false, false); // would throw

Try / catch

try {
    var match = JobMatch.parse(expr, false, false);
} catch (ExplicitException e) {
    if (e.getMessage().contains("Project criteria is not supported")) {
        // strip project criteria and reparse
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/a9ed79ba5cd63ee7. Report an issue: GitHub.