{"record":{"id":"4e163e2292df3176","repo":"theonedev/onedev","slug":"field-not-found-4e163e","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/issue/IssueQuery.java","lineNumber":572,"sourceCode":"\t\t\treturn new IssueQuery();\n\t\t}\n\t}\n\n\tprivate static GlobalIssueSetting getGlobalIssueSetting() {\n\t\tif (WicketUtils.getPage() instanceof IssueSettingPage)\n\t\t\treturn ((IssueSettingPage) WicketUtils.getPage()).getSetting();\n\t\telse\n\t\t\treturn OneDev.getInstance(SettingService.class).getIssueSetting();\n\t}\n\n\tprivate static ExplicitException newOperatorException(String fieldName, int operator) {\n\t\treturn new ExplicitException(\"Field '\" + fieldName + \"' is not applicable for operator '\" + getRuleName(operator) + \"'\");\n\t}\n\n\tpublic static void checkField(String fieldName, int operator, IssueQueryParseOption option) {\n\t\tFieldSpec fieldSpec = getGlobalIssueSetting().getFieldSpec(fieldName);\n\t\tif (fieldSpec == null && !Issue.QUERY_FIELDS.contains(fieldName))\n\t\t\tthrow new ExplicitException(\"Field not found: \" + fieldName);\n\t\tswitch (operator) {\n\t\t\tcase IsEmpty:\n\t\t\tcase IsNotEmpty:\n\t\t\t\tif (Issue.QUERY_FIELDS.contains(fieldName)\n\t\t\t\t\t\t&& !fieldName.equals(IssueSchedule.NAME_ITERATION)) {\n\t\t\t\t\tthrow newOperatorException(fieldName, operator);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase IsMe:\n\t\t\tcase IsNotMe:\n\t\t\t\tif (!(fieldSpec instanceof UserChoiceField && option.withCurrentUserCriteria()))\n\t\t\t\t\tthrow newOperatorException(fieldName, operator);\n\t\t\t\tbreak;\n\t\t\tcase IssueQueryLexer.IsCurrent:\n\t\t\t\tif (!(fieldName.equals(Issue.NAME_PROJECT) && option.withCurrentProjectCriteria()\n\t\t\t\t\t\t|| fieldSpec instanceof BuildChoiceField && option.withCurrentBuildCriteria()\n\t\t\t\t\t\t|| fieldSpec instanceof PullRequestChoiceField && option.withCurrentPullRequestCriteria()\n\t\t\t\t\t\t|| fieldSpec instanceof CommitField && option.withCurrentCommitCriteria()))","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/issue/IssueQuery.java#L554-L590","documentation":"IssueQuery.checkField validates that a field name used in an issue query criterion exists. It throws ExplicitException when getFieldSpec returns null and the name is not one of Issue.QUERY_FIELDS, i.e. the field is neither a built-in query field nor a custom field defined in the global issue setting.","triggerScenarios":"Calling checkField (via parse of field-operator or field-operator-value criteria) with a field name absent from Issue.QUERY_FIELDS and from the custom field specs.","commonSituations":"Misspelled field in a saved query; custom field renamed or deleted after queries were written; query copied from another project/instance with different custom fields.","solutions":["Fix the field name to an existing built-in query field or custom field.","Define the missing custom field in the global issue setting if it should exist.","Update saved queries/reports after renaming or deleting custom fields.","List available fields (issue setting field specs) to discover valid names."],"exampleFix":"// before\n\"State is Open\"\n// after (valid field name)\n\"Status is Open\"","handlingStrategy":"validation","validationCode":"// Check field existence before building/using a query\nvar setting = OneDev.getInstance(SettingManager.class).getIssueSetting();\nboolean valid = Issue.QUERY_FIELDS.contains(fieldName)\n    || setting.getFieldSpecs().stream().anyMatch(s -> s.getName().equals(fieldName));\nif (!valid) throw new IllegalArgumentException(\"Field not found: \" + fieldName);","typeGuard":null,"tryCatchPattern":"// catch during parse\ntry {\n    IssueQuery query = IssueQuery.parse(option, queryString);\n} catch (ExplicitException e) {\n    reportInvalidField(e.getMessage());\n}","preventionTips":["Enumerate Issue.QUERY_FIELDS plus custom field specs when building query editors with autocomplete.","Re-validate saved queries whenever custom fields are renamed or deleted.","Never hardcode field names copied from another instance."],"tags":["query-parsing","validation","issue-search"],"backgroundTag":"resource-not-found","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"}