theonedev/onedev · error · ExplicitException

Unexpected operator ${operator}

Error message

Unexpected operator ${operator}

What it means

In visitFieldOperatorValueCriteria, each supported (field, operator) pair is mapped to a criteria class via a switch; an operator that is not valid for the given field falls through to the default branch and throws ExplicitException('Unexpected operator <name>').

Source

Thrown at server-core/src/main/java/io/onedev/server/search/entity/project/ProjectQuery.java:204

											criterias.add(new PathCriteria(value, operator));
											break;
										default:
											criterias.add(new LabelCriteria(getLabelSpec(value), operator));
									}
									break;
								case IsGreaterThan:
								case IsLessThan:
									criterias.add(new IdCriteria(getLongValue(value), operator));
									break;
								case Contains:
									criterias.add(new DescriptionCriteria(value));
									break;
								case IsUntil:
								case IsSince:
									criterias.add(new LastActivityDateCriteria(value, operator));
									break;
								default:
									throw new ExplicitException("Unexpected operator " + getRuleName(operator));
							}
						}
						return operator==IsNot? Criteria.andCriterias(criterias): Criteria.orCriterias(criterias);
					}
					
					@Override
					public Criteria<Project> visitOrCriteria(OrCriteriaContext ctx) {
						List<Criteria<Project>> childCriterias = new ArrayList<>();
						for (CriteriaContext childCtx: ctx.criteria())
							childCriterias.add(visit(childCtx));
						return new OrCriteria<>(childCriterias);
					}

					@Override
					public Criteria<Project> visitAndCriteria(AndCriteriaContext ctx) {
						List<Criteria<Project>> childCriterias = new ArrayList<>();
						for (CriteriaContext childCtx: ctx.criteria())
							childCriterias.add(visit(childCtx));

View on GitHub (pinned to d44925c47c)

Solutions

  1. Use an operator supported for the field (check ProjectQuery.checkField's switch for allowed pairs).
  2. For date fields use Is/IsUntil/IsSince as appropriate; for name use ==/!=/contains.
  3. Catch ExplicitException and surface 'operator X not supported for field Y' to the user.
  4. Consult getRuleName output to map the numeric token back to the operator keyword.

Example fix

// before
"name is-since \"2024-01-01\""  // operator invalid for name
// after
"last activity is-since \"2024-01-01\""
Defensive patterns

Strategy: validation

Validate before calling

ProjectQuery.checkField(fieldName, operatorToken); // throws with details before parse-time

Type guard

null

Try / catch

try { q = ProjectQuery.parse(text); } catch (ExplicitException e) { displayOperatorError(e); }

Prevention

When it happens

Trigger: A project query like 'name is-since "x"' where the operator token is grammatically valid but not implemented for that specific field.

Common situations: Users typing operators valid for other entity types (e.g. 'submitted since') on project fields; auto-generated queries after operator renames between versions.

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