theonedev/onedev · error · ExplicitException

Field not found: ${fieldName}

Error message

Field not found: ${fieldName}

What it means

checkField (called during parsing of field-operator-value criteria) validates the field name against Project.QUERY_FIELDS and then against per-operator constraints; an unknown field name throws ExplicitException('Field not found: X') (operator mismatches get a separate message).

Source

Thrown at server-core/src/main/java/io/onedev/server/search/entity/project/ProjectQuery.java:268

				} else {
					projectSort.setDirection(sortField.getDefaultDirection());
				}
				projectSorts.add(projectSort);
			}
			
			return new ProjectQuery(projectCriteria, projectSorts);
		} else {
			return new ProjectQuery();
		}
	}
	
	private static ExplicitException newOperatorException(String fieldName, int operator) {
		return new ExplicitException("Field '" + fieldName + "' is not applicable for operator '" + getRuleName(operator) + "'");
	}
	
	public static void checkField(String fieldName, int operator) {
		if (!Project.QUERY_FIELDS.contains(fieldName))
			throw new ExplicitException("Field not found: " + fieldName);
		switch (operator) {
			case Contains:
				if (!fieldName.equals(Project.NAME_DESCRIPTION))
					throw newOperatorException(fieldName, operator);
				break;
			case Is:
			case IsNot:
				if (!fieldName.equals(Project.NAME_NAME)
						&& !fieldName.equals(Project.NAME_ID)
						&& !fieldName.equals(Project.NAME_KEY)
						&& !fieldName.equals(Project.NAME_LABEL)
						&& !fieldName.equals(Project.NAME_SERVICE_DESK_EMAIL_ADDRESS)
						&& !fieldName.equals(Project.NAME_PATH)) {
					throw newOperatorException(fieldName, operator);
				}
				break;
			case IsGreaterThan:
			case IsLessThan:

View on GitHub (pinned to d44925c47c)

Solutions

  1. Use a field in Project.QUERY_FIELDS (e.g. "name", "name description", "last activity").
  2. Fix spelling/quotes; field names in queries must match the lexer keywords exactly.
  3. Catch ExplicitException and list valid fields in the error surfaced to the user.
  4. Call ProjectQuery.checkField(fieldName, operator) in your own code to validate before building queries.

Example fix

// before
"titel == \"foo\""  // typo
// after
"name == \"foo\""
Defensive patterns

Strategy: validation

Validate before calling

try { ProjectQuery.checkField(fieldName, operator); } catch (ExplicitException e) { /* invalid field */ }

Type guard

null

Try / catch

try { q = ProjectQuery.parse(text); } catch (ExplicitException e) { showFieldHints(Project.QUERY_FIELDS); }

Prevention

When it happens

Trigger: A project query criterion like "nonexistent == \"x\"" where the field name is not in Project.QUERY_FIELDS; also hit indirectly whenever visitFieldOperatorValueCriteria processes each parsed criterion.

Common situations: Typos in field names; using fields from issue/pull-request queries in project queries; renamed fields across OneDev upgrades.

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