theonedev/onedev · error · ExplicitException

Unexpected operator:

Error message

Unexpected operator: 

What it means

Fallback branch of visitOperatorCriteria: if the ANTLR operator token type is none of the recognized cases (Online/Offline/Paused/HasRunningBuilds), the parser throws ExplicitException "Unexpected operator: <text>".

Source

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

						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)
							throw new ExplicitException("Criteria '" + ctx.operator.getText() + "' is not supported here");
						
						var criterias = new ArrayList<Criteria<Agent>>();
						for (var quoted: ctx.criteriaValue.Quoted()) {
							String value = getValue(quoted.getText());
							if (ctx.HasAttribute() != null)
								criterias.add(new HasAttributeCriteria(value));
							else if (ctx.NotUsedSince() != null)
								criterias.add(new NotUsedSinceCriteria(value));
							else if (ctx.EverUsedSince() != null)
								criterias.add(new EverUsedSinceCriteria(value));
							else if (ctx.RanBuild() != null)

View on GitHub (pinned to d44925c47c)

Solutions

  1. Use a supported operator: online, offline, paused, or has running builds
  2. Fix the typo/keyword spelling in the query
  3. Upgrade OneDev so the parser recognizes the newer operator

Example fix

// before
q = "runnin" // typo
// after
q = "has running builds"
Defensive patterns

Strategy: validation

Validate before calling

Set.of("online","offline","paused","has running builds").contains(op); // must be true before parsing

Try / catch

try { new AgentQuery(q, forRunner); } catch (ExplicitException e) { /* unknown operator — fix spelling */ }

Prevention

When it happens

Trigger: A new or unexpected operator token reaches visitOperatorCriteria without a corresponding switch case — typically after grammar changes or an unrecognized keyword in the query.

Common situations: Running a newer client query against an older parser; typo in an operator keyword that the lexer still tokenizes as operator; plugin/extension adding new operators.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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