theonedev/onedev · error · ExplicitException
"Unexpected operator: " + ctx.operator.getText()
Error message
"Unexpected operator: " + ctx.operator.getText()
What it means
Fallback branch of visitOperatorCriteria: any operator token that reaches the switch's default (i.e. an operator the pull-request criteria visitor does not handle) triggers this ExplicitException. It indicates a query operator that exists in the lexer but has no criteria implementation for this entity context, or a malformed/foreign operator.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/pullrequest/PullRequestQuery.java:221
if (!withCurrentUserCriteria)
throw new ExplicitException("Criteria '" + ctx.operator.getText() + "' is not supported here");
return new ApprovedByMeCriteria();
case AssignedToMe:
if (!withCurrentUserCriteria)
throw new ExplicitException("Criteria '" + ctx.operator.getText() + "' is not supported here");
return new AssignedToMeCriteria();
case SomeoneRequestedForChanges:
return new SomeoneRequestedForChangesCriteria();
case HasUnsuccessfulBuilds:
return new HasUnsuccessfulBuilds();
case HasMergeConflicts:
return new HasMergeConflictsCriteria();
case HasUnfinishedBuilds:
return new HasUnfinishedBuildsCriteria();
case HasPendingReviews:
return new HasPendingReviewsCriteria();
default:
throw new ExplicitException("Unexpected operator: " + ctx.operator.getText());
}
}
@Override
public Criteria<PullRequest> visitOperatorValueCriteria(OperatorValueCriteriaContext ctx) {
List<Criteria<PullRequest>> criterias = new ArrayList<>();
for (var quoted: ctx.criteriaValue.Quoted()) {
String value = getValue(quoted.getText());
switch (ctx.operator.getType()) {
case ToBeReviewedBy:
criterias.add(new ToBeReviewedByUserCriteria(getUser(value)));
break;
case ToBeChangedBy:
criterias.add(new ToBeChangedByUserCriteria(getUser(value)));
break;
case ToBeMergedBy:
criterias.add(new ToBeMergedByUserCriteria(getUser(value)));
break;View on GitHub (pinned to d44925c47c)
Solutions
- Check the operator keyword against the pull request query help/docs for the correct spelling and form.
- If the operator needs values (e.g. 'submitted by ...'), write it in operator-value form rather than bare operator form.
- Verify you are using the right entity query type (PullRequestQuery vs IssueQuery/BuildQuery).
- If it occurs after an upgrade with a valid query, report/reproduce with the exact query string and check OneDev release notes for operator changes.
Example fix
// before
PullRequestQuery.parse("state is something-bogus"); // default -> throw
// after
PullRequestQuery.parse("state is open"); Defensive patterns
Strategy: validation
Validate before calling
const PR_OPERATORS = ["state","to build","pending","submitted by","commented by","assigned to","requested for changes by","approved by","includes commit","includes issue"]; // reject tokens outside this set before calling PullRequestQuery.parse
Type guard
function isPullRequestOperator(op) {
return PR_OPERATORS.some(k => op.startsWith(k));
} Try / catch
try {
PullRequestQuery.parse(query);
} catch (ExplicitException e) {
if (e.getMessage().startsWith("Unexpected operator"))
log.warn("Unsupported PR operator in query: " + query);
throw e;
} Prevention
- Do not copy operators from issue/build queries into pull request queries
- Consult the entity's query help for valid operator names
- Test generated queries in the UI query editor before automating them
When it happens
Trigger: Parsing a pull request query whose operator token is not one of the handled pull-request operators, so the switch in visitOperatorCriteria falls through to default. Typically a copy-pasted query from another entity (issue/build) or an operator valid only in value-criteria form.
Common situations: Copying an issue query into a pull request search; typos or localized operator keywords; internal lexer/visitor mismatch after OneDev upgrades.
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
- "Field not found: " + fieldName
- Reviewer not found:
- Pull request submitter cannot be reviewer
- Assignee not found:
- No permission to read code of source project:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/3391ea0a1291c197.
Report an issue: GitHub.