theonedev/onedev · error · ExplicitException

"Unexpected operator: " + ctx.operator.getText()

Error message

"Unexpected operator: " + ctx.operator.getText()

What it means

In visitOperatorCriteria, any bare operator token that is not Active, Inactive, or (conditionally) CreatedByMe falls into the default branch and throws an ExplicitException 'Unexpected operator'. It means a value-less operator appeared where only those are grammatically/semantically valid.

Source

Thrown at server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java:131

			Criteria<Workspace> workspaceCriteria;
			if (criteriaContext != null) {
				workspaceCriteria = new WorkspaceQueryBaseVisitor<Criteria<Workspace>>() {

					@Override
					public Criteria<Workspace> visitOperatorCriteria(OperatorCriteriaContext ctx) {
						switch (ctx.operator.getType()) {
						case Pending:
							return new PendingCriteria();
						case Active:
							return new ActiveCriteria();
						case Inactive:
							return new InactiveCriteria();
						case WorkspaceQueryLexer.CreatedByMe:
							if (!withCurrentUserCriteria)
								throw new ExplicitException("Criteria '" + ctx.operator.getText() + "' is not supported here");
							return new CreatedByMeCriteria();
						default:
							throw new ExplicitException("Unexpected operator: " + ctx.operator.getText());
						}
					}

					@Override
					public Criteria<Workspace> visitOperatorValueCriteria(OperatorValueCriteriaContext ctx) {
						var criterias = new ArrayList<Criteria<Workspace>>();
						for (var quoted : ctx.criteriaValue.Quoted()) {
							String value = getValue(quoted.getText());
							if (ctx.CreatedBy() != null)
								criterias.add(new CreatedByUserCriteria(getUser(value)));
							else if (ctx.RanOn() != null)
								criterias.add(new RanOnCriteria(value));
							else
								throw new ExplicitException("Unexpected operator: " + ctx.operator.getText());
						}
						return Criteria.orCriterias(criterias);
					}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Supply the required quoted value for the operator, e.g. `ran on "agent-1"`.
  2. Only use Active, Inactive, or CreatedByMe as bare operators.
  3. Re-check the query against the workspace query grammar.

Example fix

// before
ran on
// after
ran on "build-agent-1"
Defensive patterns

Strategy: try-catch

Validate before calling

Set<String> bareOperators = Set.of("active", "inactive", "created by me");
boolean hasUnknownBareOperator = /* tokenize query and check */ false;

Try / catch

try {
    var query = WorkspaceQuery.parse(queryText);
} catch (ExplicitException e) {
    // surface e.getMessage() (Unexpected operator) to the user
}

Prevention

When it happens

Trigger: A query using a bare (valueless) operator that requires a value, e.g. `name` or `ran on` without a quoted value in the operator-criteria position.

Common situations: Hand-edited queries dropping the quoted value; grammar ambiguities letting a value-operator parse as an operator criteria.

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