{"record":{"id":"a0c543b9afc41bd1","repo":"theonedev/onedev","slug":"criteria-ctx-operator-gettext-is-not-a0c543","errorCode":null,"errorMessage":"\"Criteria '\" + ctx.operator.getText() + \"' is not supported here\"","messagePattern":"\"Criteria '\" \\+ ctx\\.operator\\.getText\\(\\) \\+ \"' is not supported here\"","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java","lineNumber":128,"sourceCode":"\t\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\t\tQueryContext queryContext = parser.query();\n\t\t\tCriteriaContext criteriaContext = queryContext.criteria();\n\t\t\tCriteria<Workspace> workspaceCriteria;\n\t\t\tif (criteriaContext != null) {\n\t\t\t\tworkspaceCriteria = new WorkspaceQueryBaseVisitor<Criteria<Workspace>>() {\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<Workspace> visitOperatorCriteria(OperatorCriteriaContext ctx) {\n\t\t\t\t\t\tswitch (ctx.operator.getType()) {\n\t\t\t\t\t\tcase Pending:\n\t\t\t\t\t\t\treturn new PendingCriteria();\n\t\t\t\t\t\tcase Active:\n\t\t\t\t\t\t\treturn new ActiveCriteria();\n\t\t\t\t\t\tcase Inactive:\n\t\t\t\t\t\t\treturn new InactiveCriteria();\n\t\t\t\t\t\tcase WorkspaceQueryLexer.CreatedByMe:\n\t\t\t\t\t\t\tif (!withCurrentUserCriteria)\n\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\treturn new CreatedByMeCriteria();\n\t\t\t\t\t\tdefault:\n\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<Workspace> visitOperatorValueCriteria(OperatorValueCriteriaContext ctx) {\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\t\tif (ctx.CreatedBy() != null)\n\t\t\t\t\t\t\t\tcriterias.add(new CreatedByUserCriteria(getUser(value)));\n\t\t\t\t\t\t\telse if (ctx.RanOn() != null)\n\t\t\t\t\t\t\t\tcriterias.add(new RanOnCriteria(value));\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tthrow new ExplicitException(\"Unexpected operator: \" + ctx.operator.getText());\n\t\t\t\t\t\t}","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/workspace/WorkspaceQuery.java#L110-L146","documentation":"During parsing of an operator-only criterion (e.g. Active, Inactive, CreatedByMe), CreatedByMe is only allowed when the query context supports current-user criteria. Otherwise an ExplicitException naming the unsupported operator is thrown. The default case catches any operator not valid without a value.","triggerScenarios":"A query like `created by me` parsed with withCurrentUserCriteria=false (e.g. parsed on behalf of anonymous/non-user context).","commonSituations":"Using 'created by me' in contexts where no current user exists, such as queries evaluated by agents or system jobs.","solutions":["Replace 'created by me' with an explicit user criterion like 'created by \"username\"'.","Use the query only in a context with an authenticated current user."],"exampleFix":"// before\ncreated by me   // parsed without current-user context\n// after\ncreated by \"john\"","handlingStrategy":"try-catch","validationCode":"if (queryText.contains(\"created by me\") && currentUser == null)\n    throw new IllegalArgumentException(\"'created by me' requires an authenticated user context\");","typeGuard":null,"tryCatchPattern":"try {\n    var query = WorkspaceQuery.parse(queryText);\n} catch (ExplicitException e) {\n    // rewrite query without 'created by me' or report to user\n}","preventionTips":["Only parse queries in authenticated user contexts","Prefer explicit 'created by \"user\"' over 'created by me' in system contexts"],"tags":["search","query","criteria"],"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"}