{"record":{"id":"3391ea0a1291c197","repo":"theonedev/onedev","slug":"unexpected-operator-ctx-operator-gettext-3391ea","errorCode":null,"errorMessage":"\"Unexpected operator: \" + ctx.operator.getText()","messagePattern":"\"Unexpected operator: \" \\+ ctx\\.operator\\.getText\\(\\)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/pullrequest/PullRequestQuery.java","lineNumber":221,"sourceCode":"\t\t\t\t\t\t\t\tif (!withCurrentUserCriteria)\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 ApprovedByMeCriteria();\n\t\t\t\t\t\t\tcase AssignedToMe:\n\t\t\t\t\t\t\t\tif (!withCurrentUserCriteria)\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 AssignedToMeCriteria();\n\t\t\t\t\t\t\tcase SomeoneRequestedForChanges:\n\t\t\t\t\t\t\t\treturn new SomeoneRequestedForChangesCriteria();\n\t\t\t\t\t\t\tcase HasUnsuccessfulBuilds:\n\t\t\t\t\t\t\t\treturn new HasUnsuccessfulBuilds();\n\t\t\t\t\t\t\tcase HasMergeConflicts:\n\t\t\t\t\t\t\t\treturn new HasMergeConflictsCriteria();\n\t\t\t\t\t\t\tcase HasUnfinishedBuilds:\n\t\t\t\t\t\t\t\treturn new HasUnfinishedBuildsCriteria();\n\t\t\t\t\t\t\tcase HasPendingReviews:\n\t\t\t\t\t\t\t\treturn new HasPendingReviewsCriteria();\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<PullRequest> visitOperatorValueCriteria(OperatorValueCriteriaContext ctx) {\n\t\t\t\t\t\tList<Criteria<PullRequest>> criterias = new ArrayList<>();\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\t\tswitch (ctx.operator.getType()) {\n\t\t\t\t\t\t\t\tcase ToBeReviewedBy:\n\t\t\t\t\t\t\t\t\tcriterias.add(new ToBeReviewedByUserCriteria(getUser(value)));\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase ToBeChangedBy:\n\t\t\t\t\t\t\t\t\tcriterias.add(new ToBeChangedByUserCriteria(getUser(value)));\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase ToBeMergedBy:\n\t\t\t\t\t\t\t\t\tcriterias.add(new ToBeMergedByUserCriteria(getUser(value)));\n\t\t\t\t\t\t\t\t\tbreak;","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/pullrequest/PullRequestQuery.java#L203-L239","documentation":"Fallback branch of visitOperatorCriteria: any operator token that reaches the switch's default (i.e. an operator the pull-request criteria visitor does not handle) triggers this ExplicitException. It indicates a query operator that exists in the lexer but has no criteria implementation for this entity context, or a malformed/foreign operator.","triggerScenarios":"Parsing a pull request query whose operator token is not one of the handled pull-request operators, so the switch in visitOperatorCriteria falls through to default. Typically a copy-pasted query from another entity (issue/build) or an operator valid only in value-criteria form.","commonSituations":"Copying an issue query into a pull request search; typos or localized operator keywords; internal lexer/visitor mismatch after OneDev upgrades.","solutions":["Check the operator keyword against the pull request query help/docs for the correct spelling and form.","If the operator needs values (e.g. 'submitted by ...'), write it in operator-value form rather than bare operator form.","Verify you are using the right entity query type (PullRequestQuery vs IssueQuery/BuildQuery).","If it occurs after an upgrade with a valid query, report/reproduce with the exact query string and check OneDev release notes for operator changes."],"exampleFix":"// before\nPullRequestQuery.parse(\"state is something-bogus\"); // default -> throw\n// after\nPullRequestQuery.parse(\"state is open\");","handlingStrategy":"validation","validationCode":"const PR_OPERATORS = [\"state\",\"to build\",\"pending\",\"submitted by\",\"commented by\",\"assigned to\",\"requested for changes by\",\"approved by\",\"includes commit\",\"includes issue\"];\n// reject tokens outside this set before calling PullRequestQuery.parse","typeGuard":"function isPullRequestOperator(op) {\n    return PR_OPERATORS.some(k => op.startsWith(k));\n}","tryCatchPattern":"try {\n    PullRequestQuery.parse(query);\n} catch (ExplicitException e) {\n    if (e.getMessage().startsWith(\"Unexpected operator\"))\n        log.warn(\"Unsupported PR operator in query: \" + query);\n    throw e;\n}","preventionTips":["Do not copy operators from issue/build queries into pull request queries","Consult the entity's query help for valid operator names","Test generated queries in the UI query editor before automating them"],"tags":["query-parser","onedev","pull-request"],"backgroundTag":"invalid-enum-value","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"}