{"record":{"id":"102297ed4159a1aa","repo":"theonedev/onedev","slug":"unexpected-field-fieldname","errorCode":null,"errorMessage":"\"Unexpected field: \" + fieldName","messagePattern":"\"Unexpected field: \" \\+ fieldName","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java","lineNumber":176,"sourceCode":"\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Workspace> visitNumberCriteria(NumberCriteriaContext ctx) {\n\t\t\t\t\t\treturn new NumberCriteria(getNumber(ctx.getText()), WorkspaceQueryParser.Is);\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Workspace> visitFieldOperatorCriteria(FieldOperatorCriteriaContext ctx) {\n\t\t\t\t\t\tString fieldName = getValue(ctx.criteriaField.getText());\n\t\t\t\t\t\tint operator = ctx.operator.getType();\n\t\t\t\t\t\tcheckField(fieldName, operator);\n\t\t\t\t\t\tif (fieldName.equals(NAME_ISSUE))\n\t\t\t\t\t\t\treturn new IssueEmptyCriteria(operator);\n\t\t\t\t\t\telse if (fieldName.equals(NAME_PULL_REQUEST))\n\t\t\t\t\t\t\treturn new PullRequestEmptyCriteria(operator);\n\t\t\t\t\t\telse if (fieldName.equals(NAME_BRANCH))\n\t\t\t\t\t\t\treturn new BranchEmptyCriteria(operator);\n\t\t\t\t\t\tthrow new ExplicitException(\"Unexpected field: \" + fieldName);\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Workspace> visitFieldOperatorValueCriteria(FieldOperatorValueCriteriaContext ctx) {\n\t\t\t\t\t\tString fieldName = getValue(ctx.criteriaField.getText());\n\t\t\t\t\t\tint operator = ctx.operator.getType();\n\t\t\t\t\t\tcheckField(fieldName, operator);\n\n\t\t\t\t\t\tvar criterias = new ArrayList<Criteria<Workspace>>();\n\t\t\t\t\t\tfor (var quoted : ctx.criteriaValue.Quoted()) {\n\t\t\t\t\t\t\tString value = getValue(quoted.getText());\n\t\t\t\t\t\tswitch (fieldName) {\n\t\t\t\t\t\t\tcase NAME_NUMBER:\n\t\t\t\t\t\t\t\tcriterias.add(new NumberCriteria(getNumber(value), operator));\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase NAME_PROJECT:\n\t\t\t\t\t\t\t\tcriterias.add(new ProjectCriteria(value, operator));\n\t\t\t\t\t\t\t\tbreak;","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java#L158-L194","documentation":"visitFieldOperatorCriteria handles empty/not-empty checks on fields; only issue, pull request, and branch are supported. Any other field name reaching the end throws ExplicitException 'Unexpected field'.","triggerScenarios":"A query like `name is empty` or `commit is empty` — fields that don't support the empty/not-empty operator.","commonSituations":"Applying empty/not-empty to scalar fields (name, number, project) that are never empty; copy-pasted queries from other entity types.","solutions":["Use empty/not-empty only with issue, pull request, or branch fields.","For other fields use equality/inequality or contains operators instead.","Run WorkspaceQuery.checkField to validate field/operator combos before parsing."],"exampleFix":"// before\nname is empty\n// after\nname is \"foo\"","handlingStrategy":"validation","validationCode":"Set<String> emptyCheckFields = Set.of(\"issue\", \"pull request\", \"branch\");\nif (queryText.matches(\".*(\\\\w+)\\\\s+is\\\\s+(empty|not empty).*\") && !emptyCheckFields.contains(fieldName))\n    throw new IllegalArgumentException(\"Field \" + fieldName + \" does not support empty checks\");","typeGuard":null,"tryCatchPattern":"try {\n    WorkspaceQuery.checkField(fieldName, operator);\n    var query = WorkspaceQuery.parse(queryText);\n} catch (ExplicitException e) { /* handle */ }","preventionTips":["Apply empty/not-empty only to issue, pull request, branch fields","Call WorkspaceQuery.checkField before parsing user queries"],"tags":["search","query","fields"],"backgroundTag":"unsupported-operation","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}