theonedev/onedev · error · ExplicitException
"Unexpected field: " + fieldName
Error message
"Unexpected field: " + fieldName
What it means
visitFieldOperatorCriteria handles empty/not-empty checks on fields; only issue, pull request, and branch are supported. Any other field name reaching the end throws ExplicitException 'Unexpected field'.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java:176
}
@Override
public Criteria<Workspace> visitNumberCriteria(NumberCriteriaContext ctx) {
return new NumberCriteria(getNumber(ctx.getText()), WorkspaceQueryParser.Is);
}
@Override
public Criteria<Workspace> visitFieldOperatorCriteria(FieldOperatorCriteriaContext ctx) {
String fieldName = getValue(ctx.criteriaField.getText());
int operator = ctx.operator.getType();
checkField(fieldName, operator);
if (fieldName.equals(NAME_ISSUE))
return new IssueEmptyCriteria(operator);
else if (fieldName.equals(NAME_PULL_REQUEST))
return new PullRequestEmptyCriteria(operator);
else if (fieldName.equals(NAME_BRANCH))
return new BranchEmptyCriteria(operator);
throw new ExplicitException("Unexpected field: " + fieldName);
}
@Override
public Criteria<Workspace> visitFieldOperatorValueCriteria(FieldOperatorValueCriteriaContext ctx) {
String fieldName = getValue(ctx.criteriaField.getText());
int operator = ctx.operator.getType();
checkField(fieldName, operator);
var criterias = new ArrayList<Criteria<Workspace>>();
for (var quoted : ctx.criteriaValue.Quoted()) {
String value = getValue(quoted.getText());
switch (fieldName) {
case NAME_NUMBER:
criterias.add(new NumberCriteria(getNumber(value), operator));
break;
case NAME_PROJECT:
criterias.add(new ProjectCriteria(value, operator));
break;View on GitHub (pinned to d44925c47c)
Solutions
- Use empty/not-empty only with issue, pull request, or branch fields.
- For other fields use equality/inequality or contains operators instead.
- Run WorkspaceQuery.checkField to validate field/operator combos before parsing.
Example fix
// before name is empty // after name is "foo"
Defensive patterns
Strategy: validation
Validate before calling
Set<String> emptyCheckFields = Set.of("issue", "pull request", "branch");
if (queryText.matches(".*(\\w+)\\s+is\\s+(empty|not empty).*") && !emptyCheckFields.contains(fieldName))
throw new IllegalArgumentException("Field " + fieldName + " does not support empty checks"); Try / catch
try {
WorkspaceQuery.checkField(fieldName, operator);
var query = WorkspaceQuery.parse(queryText);
} catch (ExplicitException e) { /* handle */ } Prevention
- Apply empty/not-empty only to issue, pull request, branch fields
- Call WorkspaceQuery.checkField before parsing user queries
When it happens
Trigger: A query like `name is empty` or `commit is empty` — fields that don't support the empty/not-empty operator.
Common situations: Applying empty/not-empty to scalar fields (name, number, project) that are never empty; copy-pasted queries from other entity types.
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
- "Criteria '" + ctx.operator.getText() + "' is not supported
- "Unexpected operator: " + ctx.operator.getText()
- "Cannot order by field: " + fieldName
- "Field not found: " + fieldName
- Invalid fields:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/102297ed4159a1aa.
Report an issue: GitHub.