theonedev/onedev · error · ExplicitException
"Field not found: " + fieldName
Error message
"Field not found: " + fieldName
What it means
checkField validates a field name/operator pair for workspace queries. If the field name is not in QUERY_FIELDS it throws ExplicitException 'Field not found'; it then also validates which operators the field supports.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java:283
if (order.direction.getText().equals("desc"))
workspaceSort.setDirection(DESCENDING);
else
workspaceSort.setDirection(ASCENDING);
} else {
workspaceSort.setDirection(sortField.getDefaultDirection());
}
workspaceSorts.add(workspaceSort);
}
return new WorkspaceQuery(workspaceCriteria, workspaceSorts);
} else {
return new WorkspaceQuery();
}
}
public static void checkField(String fieldName, int operator) {
if (!QUERY_FIELDS.contains(fieldName))
throw new ExplicitException("Field not found: " + fieldName);
switch (operator) {
case Is:
case IsNot:
if (!fieldName.equals(NAME_NUMBER) && !fieldName.equals(NAME_PROJECT)
&& !fieldName.equals(NAME_ISSUE) && !fieldName.equals(NAME_PULL_REQUEST)
&& !fieldName.equals(NAME_BRANCH) && !fieldName.equals(NAME_COMMIT)
&& !fieldName.equals(NAME_SPEC)) {
throw newOperatorException(fieldName, operator);
}
break;
case IsEmpty:
case IsNotEmpty:
if (!fieldName.equals(NAME_ISSUE) && !fieldName.equals(NAME_PULL_REQUEST)
&& !fieldName.equals(NAME_BRANCH))
throw newOperatorException(fieldName, operator);
break;
case IsGreaterThan:
case IsLessThan:View on GitHub (pinned to d44925c47c)
Solutions
- Use a field from WorkspaceQuery.QUERY_FIELDS (name, number, project, issue, pull request, branch, commit, submit date, create date, active date).
- Correct the field name spelling in the query.
- Call checkField in a try-catch when validating user-supplied queries to give feedback.
- Check the WorkspaceQuery.g4 grammar for the canonical field list.
Example fix
// before assignee is "john" // not a workspace query field // after created by "john"
Defensive patterns
Strategy: try-catch
Validate before calling
try {
WorkspaceQuery.checkField(fieldName, operator);
} catch (ExplicitException e) {
// field invalid or operator unsupported for field — prompt user
} Try / catch
try {
WorkspaceQuery.checkField(fieldName, operator);
} catch (ExplicitException e) {
throw new IllegalArgumentException("Invalid field/operator: " + e.getMessage());
} Prevention
- Validate field/operator pairs with checkField before parsing
- Keep a canonical field list mirrored from QUERY_FIELDS
- Version persisted queries and migrate on upgrades
When it happens
Trigger: Calling WorkspaceQuery.checkField (directly or via visitFieldOperatorCriteria/visitFieldOperatorValueCriteria) with a fieldName not contained in QUERY_FIELDS.
Common situations: Typo in a query field; using fields from other entity query grammars; queries persisted against older OneDev versions whose fields changed.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
- Field not found: ${fieldName}
- Criteria '${operator}' is not supported here
- Unexpected operator: ${operator}
- Unexpected criteria: ${operator}
- Cannot order by field: ${fieldName}
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/1c57052990121538.
Report an issue: GitHub.