theonedev/onedev · error · ExplicitException

Criteria '' is not supported here

Error message

Criteria '' is not supported here

What it means

In AgentQuery's visitor, operator-only criteria (online/offline/paused/has running builds) are not allowed when the query is parsed for a runner (forRunner=true); the parser throws ExplicitException "Criteria '<op>' is not supported here".

Source

Thrown at server-core/src/main/java/io/onedev/server/search/entity/agent/AgentQuery.java:104

			CommonTokenStream tokens = new CommonTokenStream(lexer);
			AgentQueryParser parser = new AgentQueryParser(tokens);
			parser.removeErrorListeners();
			parser.setErrorHandler(new BailErrorStrategy());
			QueryContext queryContext = parser.query();
			CriteriaContext criteriaContext = queryContext.criteria();
			Criteria<Agent> agentCriteria;
			if (criteriaContext != null) {
				agentCriteria = new AgentQueryBaseVisitor<Criteria<Agent>>() {

					@Override
					public Criteria<Agent> visitFuzzyCriteria(FuzzyCriteriaContext ctx) {
						return new FuzzyCriteria(getValue(ctx.getText()));
					}
					
					@Override
					public Criteria<Agent> visitOperatorCriteria(OperatorCriteriaContext ctx) {
						if (forRunner)
							throw new ExplicitException("Criteria '" + ctx.operator.getText() + "' is not supported here");
						
						switch (ctx.operator.getType()) {
						case Online:
							return new OnlineCriteria();
						case Offline:
							return new OfflineCriteria();
						case Paused:
							return new PausedCriteria();
						case HasRunningBuilds:
							return new HasRunningBuildsCriteria();
						default:
							throw new ExplicitException("Unexpected operator: " + ctx.operator.getText());
						}
					}
					
					@Override
					public Criteria<Agent> visitOperatorValueCriteria(OperatorValueCriteriaContext ctx) {
						if (forRunner && ctx.HasAttribute() == null)

View on GitHub (pinned to d44925c47c)

Solutions

  1. Remove operator criteria unsupported in the runner context
  2. Use only criteria permitted for runner queries (e.g. HasAttribute value criteria)
  3. Parse with forRunner=false if the server context is what's intended

Example fix

// before
new AgentQuery("online", true /* forRunner */)
// after
new AgentQuery("HasAttribute is \"gpu\"", true)
Defensive patterns

Strategy: validation

Validate before calling

Set<String> runnerAllowed = Set.of("HasAttribute");
for (String crit : extractCriteria(q)) if (!runnerAllowed.contains(crit) && forRunner) throw new IllegalArgumentException("unsupported in runner query: " + crit);

Try / catch

try { new AgentQuery(q, true); } catch (ExplicitException e) { /* fall back to runner-safe query */ }

Prevention

When it happens

Trigger: Parsing an agent query containing an operator criterion (e.g. 'online', 'paused') in a context where forRunner is true — i.e. a runner-facing query that only permits certain criteria.

Common situations: Writing a runner-side agent query using server-side-only operators; reusing a server query string in a runner context.

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/df1d04f125e30685. Report an issue: GitHub.