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

  1. Use a field from WorkspaceQuery.QUERY_FIELDS (name, number, project, issue, pull request, branch, commit, submit date, create date, active date).
  2. Correct the field name spelling in the query.
  3. Call checkField in a try-catch when validating user-supplied queries to give feedback.
  4. 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

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


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/1c57052990121538. Report an issue: GitHub.