{"record":{"id":"1c57052990121538","repo":"theonedev/onedev","slug":"field-not-found-fieldname-1c5705","errorCode":null,"errorMessage":"\"Field not found: \" + fieldName","messagePattern":"\"Field not found: \" \\+ fieldName","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java","lineNumber":283,"sourceCode":"\t\t\t\t\tif (order.direction.getText().equals(\"desc\"))\n\t\t\t\t\t\tworkspaceSort.setDirection(DESCENDING);\n\t\t\t\t\telse\n\t\t\t\t\t\tworkspaceSort.setDirection(ASCENDING);\n\t\t\t\t} else {\n\t\t\t\t\tworkspaceSort.setDirection(sortField.getDefaultDirection());\n\t\t\t\t}\n\t\t\t\tworkspaceSorts.add(workspaceSort);\n\t\t\t}\n\n\t\t\treturn new WorkspaceQuery(workspaceCriteria, workspaceSorts);\n\t\t} else {\n\t\t\treturn new WorkspaceQuery();\n\t\t}\n\t}\n\n\tpublic static void checkField(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 Is:\n\t\t\tcase IsNot:\n\t\t\t\tif (!fieldName.equals(NAME_NUMBER) && !fieldName.equals(NAME_PROJECT)\n\t\t\t\t\t\t&& !fieldName.equals(NAME_ISSUE) && !fieldName.equals(NAME_PULL_REQUEST)\n\t\t\t\t\t\t&& !fieldName.equals(NAME_BRANCH) && !fieldName.equals(NAME_COMMIT)\n\t\t\t\t\t\t&& !fieldName.equals(NAME_SPEC)) {\n\t\t\t\t\tthrow newOperatorException(fieldName, operator);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase IsEmpty:\n\t\t\tcase IsNotEmpty:\n\t\t\t\tif (!fieldName.equals(NAME_ISSUE) && !fieldName.equals(NAME_PULL_REQUEST)\n\t\t\t\t\t\t&& !fieldName.equals(NAME_BRANCH))\n\t\t\t\t\tthrow newOperatorException(fieldName, operator);\n\t\t\t\tbreak;\n\t\t\tcase IsGreaterThan:\n\t\t\tcase IsLessThan:","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java#L265-L301","documentation":"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.","triggerScenarios":"Calling WorkspaceQuery.checkField (directly or via visitFieldOperatorCriteria/visitFieldOperatorValueCriteria) with a fieldName not contained in QUERY_FIELDS.","commonSituations":"Typo in a query field; using fields from other entity query grammars; queries persisted against older OneDev versions whose fields changed.","solutions":["Use a field from WorkspaceQuery.QUERY_FIELDS (name, number, project, issue, pull request, branch, commit, submit date, create date, active date).","Correct the field name spelling in the query.","Call checkField in a try-catch when validating user-supplied queries to give feedback.","Check the WorkspaceQuery.g4 grammar for the canonical field list."],"exampleFix":"// before\nassignee is \"john\"   // not a workspace query field\n// after\ncreated by \"john\"","handlingStrategy":"try-catch","validationCode":"try {\n    WorkspaceQuery.checkField(fieldName, operator);\n} catch (ExplicitException e) {\n    // field invalid or operator unsupported for field — prompt user\n}","typeGuard":null,"tryCatchPattern":"try {\n    WorkspaceQuery.checkField(fieldName, operator);\n} catch (ExplicitException e) {\n    throw new IllegalArgumentException(\"Invalid field/operator: \" + e.getMessage());\n}","preventionTips":["Validate field/operator pairs with checkField before parsing","Keep a canonical field list mirrored from QUERY_FIELDS","Version persisted queries and migrate on upgrades"],"tags":["search","query","validation"],"backgroundTag":"invalid-query-parameter","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"}