theonedev/onedev · error · ExplicitException

Unexpected operator: ${operator}

Error message

Unexpected operator: ${operator}

What it means

PackQuery's visitor for operator criteria only recognizes the PublishedByMe operator; any other operator token reaching this switch hits the default branch and throws ExplicitException("Unexpected operator: <operator>"). It is a grammar-to-criteria mapping guard.

Source

Thrown at server-core/src/main/java/io/onedev/server/search/entity/pack/PackQuery.java:107

			QueryContext queryContext = parser.query();
			CriteriaContext criteriaContext = queryContext.criteria();
			Criteria<Pack> packCriteria;
			if (criteriaContext != null) {
				packCriteria = new PackQueryBaseVisitor<Criteria<Pack>>() {

					@Override
					public Criteria<Pack> visitFuzzyCriteria(FuzzyCriteriaContext ctx) {
						return new FuzzyCriteria(getValue(ctx.getText()));
					}
					
					public Criteria<Pack> visitOperatorCriteria(PackQueryParser.OperatorCriteriaContext ctx) {
						switch (ctx.operator.getType()) {
							case PublishedByMe:
								if (!withCurrentUserCriteria)
									throw new ExplicitException("Criteria '" + ctx.operator.getText() + "' is not supported here");
								return new PublishedByMeCriteria();
							default:
								throw new ExplicitException("Unexpected operator: " + ctx.operator.getText());
						}
					}

					@Override
					public Criteria<Pack> visitOperatorValueCriteria(PackQueryParser.OperatorValueCriteriaContext ctx) {
						var criterias = new ArrayList<Criteria<Pack>>();
						for (var quoted: ctx.criteriaValue.Quoted()) {
							String value = getValue(quoted.getText());
							if (ctx.PublishedByUser() != null)
								criterias.add(new PublishedByUserCriteria(getUser(value)));
							else if (ctx.PublishedByBuild() != null)
								criterias.add(new PublishedViaBuildCriteria(project, value));
							else if (ctx.PublishedByProject() != null)
								criterias.add(new PublishedViaProjectCriteria(value));
							else
								throw new ExplicitException("Unexpected criteria: " + ctx.operator.getText());
						}	
						return Criteria.orCriterias(criterias);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Use a supported operator ('published by me') or a field/value criterion instead
  2. Check the pack query grammar/docs for the list of valid operators
  3. If migrating from another OneDev version, update legacy operators to current syntax

Example fix

// before
"is:open" // issue-style operator on packs
// after
"published by me"
Defensive patterns

Strategy: validation

Validate before calling

const allowedOperators = ['published by me']; if (operatorToken && !allowedOperators.includes(operatorToken.toLowerCase())) throw new Error('unsupported operator: ' + operatorToken);

Type guard

null

Try / catch

try { PackQuery.parse(project, q); } catch (ExplicitException e) { if (e.getMessage().startsWith('Unexpected operator')) { showError('Operator not supported for packs: ' + e.getMessage()); } else throw e; }

Prevention

When it happens

Trigger: A pack query string containing an operator token that the pack grammar accepts lexically but has no Criteria implementation in visitOperatorCriteria — typically from grammar/parser version drift or malformed input reaching the visitor.

Common situations: Older query strings using operators removed/renamed in the pack query grammar; hand-edited saved queries; copy-pasted queries from other entity types (e.g. issue query operators) applied to packs.

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