{"record":{"id":"f77ebf9162b4abbc","repo":"theonedev/onedev","slug":"unexpected-operator-f77ebf","errorCode":null,"errorMessage":"Unexpected operator: ","messagePattern":"Unexpected operator: ","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/issue/IssueQuery.java","lineNumber":243,"sourceCode":"\t\t\t\t\t\t\t\treturn new FixedInCurrentBuildCriteria();\n\t\t\t\t\t\t\tcase FixedInCurrentPullRequest:\n\t\t\t\t\t\t\t\tif (!option.withCurrentPullRequestCriteria())\n\t\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Criteria '\" + ctx.operator.getText() + \"' is not supported here\");\n\t\t\t\t\t\t\t\treturn new FixedInCurrentPullRequestCriteria();\n\t\t\t\t\t\t\tcase FixedInCurrentCommit:\n\t\t\t\t\t\t\t\tif (!option.withCurrentCommitCriteria())\n\t\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Criteria '\" + ctx.operator.getText() + \"' is not supported here\");\n\t\t\t\t\t\t\t\treturn new FixedInCurrentCommitCriteria();\n\t\t\t\t\t\t\tcase ReferencedInCurrentBranch:\n\t\t\t\t\t\t\t\tif (!option.withCurrentBranchCriteria())\n\t\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Criteria '\" + ctx.operator.getText() + \"' is not supported here\");\n\t\t\t\t\t\t\t\treturn new ReferencedInCurrentBranchCriteria();\n\t\t\t\t\t\t\tcase CurrentIssue:\n\t\t\t\t\t\t\t\tif (!option.withCurrentIssueCriteria())\n\t\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Criteria '\" + ctx.operator.getText() + \"' is not supported here\");\n\t\t\t\t\t\t\t\treturn new CurrentIssueCriteria();\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unexpected operator: \" + ctx.operator.getText());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Issue> visitFieldOperatorCriteria(FieldOperatorCriteriaContext ctx) {\n\t\t\t\t\t\tString fieldName = getValue(ctx.Quoted().getText());\n\t\t\t\t\t\tint operator = ctx.operator.getType();\n\t\t\t\t\t\tif (validate)\n\t\t\t\t\t\t\tcheckField(fieldName, operator, option);\n\t\t\t\t\t\tif (fieldName.equals(NAME_PROJECT)) {\n\t\t\t\t\t\t\treturn new ProjectIsCurrentCriteria();\n\t\t\t\t\t\t} else if (fieldName.equals(IssueSchedule.NAME_ITERATION)) {\n\t\t\t\t\t\t\treturn new IterationEmptyCriteria(operator);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tFieldSpec fieldSpec = getGlobalIssueSetting().getFieldSpec(fieldName);\n\t\t\t\t\t\t\tif (fieldSpec != null)\n\t\t\t\t\t\t\t\treturn new FieldOperatorCriteria(fieldName, operator, fieldSpec.isAllowMultiple());\n\t\t\t\t\t\t\telse","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/issue/IssueQuery.java#L225-L261","documentation":"The CurrentIssue operator (\"Current issue\") refers to the issue being viewed, so IssueQuery.parse() accepts it only when IssueQueryParseOption.withCurrentIssueCriteria is enabled. When the flag is off, visitOperatorCriteria throws this ExplicitException. This keeps self-referential criteria out of contexts (like saved queries or issue lists) where there is no 'current issue'.","triggerScenarios":"IssueQuery.parse() is invoked with a query containing \"Current issue\" while option.withCurrentIssueCriteria() is false, e.g. parsing on a context other than the issue detail page.","commonSituations":"Using \"Current issue\" in saved queries or project-wide filters; plugins parsing query strings copied from the issue detail page with default options.","solutions":["Remove the \"Current issue\" operator from the query or replace with an explicit issue-number criterion (e.g. \"Number is 123\").","Parse with an IssueQueryParseOption that has withCurrentIssueCriteria enabled, only where a current issue exists.","Handle ExplicitException and tell the user this operator is only supported on issue-detail-scoped queries."],"exampleFix":"// before\nIssueQuery.parse(project, \"Current issue\", new IssueQueryParseOption(), true);\n// after\nIssueQueryParseOption option = new IssueQueryParseOption();\noption.withCurrentIssueCriteria(true);\nIssueQuery.parse(project, \"Current issue\", option, true);","handlingStrategy":"validation","validationCode":"if (!option.withCurrentIssueCriteria() && queryString.toLowerCase().contains(\"current issue\"))\n    throw new IllegalArgumentException(\"'Current issue' only valid in issue-detail-scoped queries\");","typeGuard":"boolean supportsCurrentIssueCriteria(IssueQueryParseOption option, String query) {\n    return option.withCurrentIssueCriteria() || !query.toLowerCase().contains(\"current issue\");\n}","tryCatchPattern":"try {\n    IssueQuery.parse(project, queryString, option, true);\n} catch (ExplicitException e) {\n    // suggest replacing with 'Number is <n>'\n    suggestQueryRewrite(e.getMessage());\n}","preventionTips":["Use 'Current issue' only where an issue detail context exists","Prefer explicit issue number criteria in saved/shared queries","Catch ExplicitException and offer a rewrite suggestion"],"tags":["onedev","issue-query","query-parsing","validation"],"backgroundTag":"unsupported-operation","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"}