theonedev/onedev · error · ExplicitException

Unexpected operator:

Error message

Unexpected operator: 

What it means

Thrown by ActionCondition's visitor when an operator token in the parsed condition is not recognized as a supported operator for the given criteria context. The switch over lexer token types falls through to default and raises an ExplicitException with the offending operator text.

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspec/job/action/condition/ActionCondition.java:124

					switch (ctx.operator.getType()) {
					case ActionConditionLexer.Successful:
						return new SuccessfulCriteria();
					case ActionConditionLexer.Failed:
						return new FailedCriteria();
					case ActionConditionLexer.Cancelled:
						return new CancelledCriteria();
					case ActionConditionLexer.TimedOut:
						return new TimedOutCriteria();
					case ActionConditionLexer.PreviousIsSuccessful:
						return new PreviousIsSuccessfulCriteria();
					case ActionConditionLexer.PreviousIsFailed:
						return new PreviousIsFailedCriteria();
					case ActionConditionLexer.PreviousIsCancelled:
						return new PreviousIsCancelledCriteria();
					case ActionConditionLexer.PreviousIsTimedOut:
						return new PreviousIsTimedOutCriteria();
					default:
						throw new ExplicitException("Unexpected operator: " + ctx.operator.getText());
					}
				}
				
				@Override
				public Criteria<Build> visitFieldOperatorCriteria(FieldOperatorCriteriaContext ctx) {
					String fieldName = getValue(ctx.Quoted().getText());
					int operator = ctx.operator.getType();
					checkField(job, fieldName, operator);
					if (fieldName.equals(NAME_BRANCH))
						return new BranchEmptyCriteria(operator);
					else if (fieldName.equals(NAME_TAG))
						return new TagEmptyCriteria(operator);
					else if (fieldName.equals(NAME_PULL_REQUEST))
						return new PullRequestEmptyCriteria(operator);
					else if (fieldName.equals(NAME_AI_PULL_REQUEST))
						return new AiPullRequestEmptyCriteria(operator);
					else
						return new ParamEmptyCriteria(fieldName, operator);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Check the operator text in the error message and replace it with a supported operator for that criterion (e.g. 'is failed', 'is successful' for previous-build criteria).
  2. Consult the action condition operator reference in OneDev docs for valid field/operator combinations.
  3. Update OneDev if the operator is documented for a newer version.

Example fix

// before
condition: previous build > failed

// after
condition: previous build is failed
Defensive patterns

Strategy: try-catch

Try / catch

try {
    ActionCondition.parse(text, job, build);
} catch (ExplicitException e) {
    if (e.getMessage().startsWith("Unexpected operator:")) {
        // show supported operator list for the criterion
    } else throw e;
}

Prevention

When it happens

Trigger: A condition expression uses an operator token that exists grammatically but has no handler in visitOperatorCriteria/visitFieldOperatorCriteria — e.g. an operator applied to a state criterion or an unsupported field operator.

Common situations: Applying comparison operators (>, <) to boolean/state criteria; using an operator added in a newer OneDev version against an older grammar, or vice versa; typos that still tokenize to an operator rule.

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