theonedev/onedev · error · ExplicitException

Field not found:

Error message

Field not found: 

What it means

checkField() validates the field name of a field-operator-value criteria (e.g. "content contains \"bug\""). If the field is not in CodeComment.QUERY_FIELDS, ExplicitException "Field not found: <name>" is thrown before any operator-specific checks. It is invoked from visitFieldOperatorValueCriteria during CodeCommentQuery.parse().

Source

Thrown at server-core/src/main/java/io/onedev/server/search/entity/codecomment/CodeCommentQuery.java:279

					if (order.direction.getText().equals("desc"))
						commentSort.setDirection(DESCENDING);
					else
						commentSort.setDirection(ASCENDING);
				} else {
					commentSort.setDirection(sortField.getDefaultDirection());
				}
				commentSorts.add(commentSort);
			}

			return new CodeCommentQuery(commentCriteria, commentSorts);
		} else {
			return new CodeCommentQuery();
		}
	}

	public static void checkField(Project project, String fieldName, int operator) {
		if (!QUERY_FIELDS.contains(fieldName))
			throw new ExplicitException("Field not found: " + fieldName);
		switch (operator) {
			case IsUntil:
			case IsSince:
				if (!fieldName.equals(NAME_CREATE_DATE) && !fieldName.equals(NAME_LAST_ACTIVITY_DATE))
					throw newOperatorException(fieldName, operator);
				break;
			case IsGreaterThan:
			case IsLessThan:
				if (!fieldName.equals(NAME_REPLY_COUNT))
					throw newOperatorException(fieldName, operator);
				break;
			case Contains:
				if (!fieldName.equals(NAME_CONTENT) && !fieldName.equals(NAME_REPLY))
					throw newOperatorException(fieldName, operator);
				break;
			case Is:
			case IsNot:
				if (!fieldName.equals(NAME_REPLY_COUNT) && !fieldName.equals(NAME_PATH))

View on GitHub (pinned to d44925c47c)

Solutions

  1. Use a valid code comment field name exactly as documented (e.g. "content", "reply", "path", "reply count", "create date", "last activity date").
  2. Verify against CodeComment.QUERY_FIELDS or the query builder UI field list.
  3. Remove or correct the mistyped criteria term.
  4. Catch ExplicitException around parse() and show the message so the user can fix the field name.

Example fix

// before
var query = CodeCommentQuery.parse(project, "title contains \"bug\"", true); // no such field
// after
var query = CodeCommentQuery.parse(project, "content contains \"bug\"", true);
Defensive patterns

Strategy: validation

Validate before calling

// valid field names for code comment criteria
static final java.util.Set<String> CODE_COMMENT_FIELDS = java.util.Set.of(
    "content", "reply", "path", "reply count", "create date", "last activity date");
static boolean isKnownField(String fieldName) {
    return CODE_COMMENT_FIELDS.contains(fieldName.toLowerCase());
}

Try / catch

try {
    var query = CodeCommentQuery.parse(project, queryString, true);
} catch (ExplicitException e) {
    if (e.getMessage().startsWith("Field not found"))
        showUserError(e.getMessage() + " — see code comment query docs for valid fields");
    else
        throw e;
}

Prevention

When it happens

Trigger: A criteria using a field name that does not exist for code comments, e.g. "state is \"Open\"" or "title contains \"x\"" — any name not in QUERY_FIELDS (valid: content, reply, path, reply count, create date, last activity date).

Common situations: Copy-pasting criteria from issue/build query languages into code comment search; typos like "replycount" instead of "reply count"; case/spacing mismatches with the documented field names.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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