{"record":{"id":"ec814a8c2169f4f3","repo":"theonedev/onedev","slug":"field-not-found","errorCode":null,"errorMessage":"Field not found: ","messagePattern":"Field not found: ","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/codecomment/CodeCommentQuery.java","lineNumber":279,"sourceCode":"\t\t\t\t\tif (order.direction.getText().equals(\"desc\"))\n\t\t\t\t\t\tcommentSort.setDirection(DESCENDING);\n\t\t\t\t\telse\n\t\t\t\t\t\tcommentSort.setDirection(ASCENDING);\n\t\t\t\t} else {\n\t\t\t\t\tcommentSort.setDirection(sortField.getDefaultDirection());\n\t\t\t\t}\n\t\t\t\tcommentSorts.add(commentSort);\n\t\t\t}\n\n\t\t\treturn new CodeCommentQuery(commentCriteria, commentSorts);\n\t\t} else {\n\t\t\treturn new CodeCommentQuery();\n\t\t}\n\t}\n\n\tpublic static void checkField(Project project, String fieldName, int operator) {\n\t\tif (!QUERY_FIELDS.contains(fieldName))\n\t\t\tthrow new ExplicitException(\"Field not found: \" + fieldName);\n\t\tswitch (operator) {\n\t\t\tcase IsUntil:\n\t\t\tcase IsSince:\n\t\t\t\tif (!fieldName.equals(NAME_CREATE_DATE) && !fieldName.equals(NAME_LAST_ACTIVITY_DATE))\n\t\t\t\t\tthrow newOperatorException(fieldName, operator);\n\t\t\t\tbreak;\n\t\t\tcase IsGreaterThan:\n\t\t\tcase IsLessThan:\n\t\t\t\tif (!fieldName.equals(NAME_REPLY_COUNT))\n\t\t\t\t\tthrow newOperatorException(fieldName, operator);\n\t\t\t\tbreak;\n\t\t\tcase Contains:\n\t\t\t\tif (!fieldName.equals(NAME_CONTENT) && !fieldName.equals(NAME_REPLY))\n\t\t\t\t\tthrow newOperatorException(fieldName, operator);\n\t\t\t\tbreak;\n\t\t\tcase Is:\n\t\t\tcase IsNot:\n\t\t\t\tif (!fieldName.equals(NAME_REPLY_COUNT) && !fieldName.equals(NAME_PATH))","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/codecomment/CodeCommentQuery.java#L261-L297","documentation":"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().","triggerScenarios":"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).","commonSituations":"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.","solutions":["Use a valid code comment field name exactly as documented (e.g. \"content\", \"reply\", \"path\", \"reply count\", \"create date\", \"last activity date\").","Verify against CodeComment.QUERY_FIELDS or the query builder UI field list.","Remove or correct the mistyped criteria term.","Catch ExplicitException around parse() and show the message so the user can fix the field name."],"exampleFix":"// before\nvar query = CodeCommentQuery.parse(project, \"title contains \\\"bug\\\"\", true); // no such field\n// after\nvar query = CodeCommentQuery.parse(project, \"content contains \\\"bug\\\"\", true);","handlingStrategy":"validation","validationCode":"// valid field names for code comment criteria\nstatic final java.util.Set<String> CODE_COMMENT_FIELDS = java.util.Set.of(\n    \"content\", \"reply\", \"path\", \"reply count\", \"create date\", \"last activity date\");\nstatic boolean isKnownField(String fieldName) {\n    return CODE_COMMENT_FIELDS.contains(fieldName.toLowerCase());\n}","typeGuard":null,"tryCatchPattern":"try {\n    var query = CodeCommentQuery.parse(project, queryString, true);\n} catch (ExplicitException e) {\n    if (e.getMessage().startsWith(\"Field not found\"))\n        showUserError(e.getMessage() + \" — see code comment query docs for valid fields\");\n    else\n        throw e;\n}","preventionTips":["Use the query builder UI to pick valid field names.","Match field spelling/spacing exactly as documented (e.g. \"reply count\", not \"replycount\").","Do not reuse field names from issue or build queries.","Catch ExplicitException around parse() to give actionable feedback."],"tags":["search-query","query-parser","invalid-field"],"backgroundTag":"invalid-argument-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}