{"record":{"id":"0720feb0d76bda1f","repo":"theonedev/onedev","slug":"criteria-is-not-supported-here-0720fe","errorCode":null,"errorMessage":"Criteria '' is not supported here","messagePattern":"Criteria '' is not supported here","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/codecomment/CodeCommentQuery.java","lineNumber":125,"sourceCode":"\t\t\tCriteriaContext criteriaContext = queryContext.criteria();\n\t\t\tCriteria<CodeComment> commentCriteria;\n\t\t\tif (criteriaContext != null) {\n\t\t\t\tcommentCriteria = new CodeCommentQueryBaseVisitor<Criteria<CodeComment>>() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<CodeComment> visitFuzzyCriteria(FuzzyCriteriaContext ctx) {\n\t\t\t\t\t\treturn new FuzzyCriteria(getValue(ctx.getText()));\n\t\t\t\t\t}\n\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic Criteria<CodeComment> visitOperatorCriteria(OperatorCriteriaContext ctx) {\n\t\t\t\t\t\tswitch (ctx.operator.getType()) {\n\t\t\t\t\t\t\tcase Resolved:\n\t\t\t\t\t\t\t\treturn new ResolvedCriteria();\n\t\t\t\t\t\t\tcase Unresolved:\n\t\t\t\t\t\t\t\treturn new UnresolvedCriteria();\n\t\t\t\t\t\t\tcase MentionedMe:\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 MentionedMeCriteria();\n\t\t\t\t\t\t\tcase CreatedByMe:\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 CreatedByMeCriteria();\n\t\t\t\t\t\t\tcase RepliedByMe:\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 RepliedByMeCriteria();\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<CodeComment> visitOperatorValueCriteria(OperatorValueCriteriaContext ctx) {\n\t\t\t\t\t\tint operator = ctx.operator.getType();\n\t\t\t\t\t\tvar criterias = new ArrayList<Criteria<CodeComment>>();","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/codecomment/CodeCommentQuery.java#L107-L143","documentation":"Inside visitOperatorCriteria, the MentionedMe criteria is only allowed when the query was parsed with withCurrentUserCriteria=true. When parsing in a context that disallows current-user-dependent criteria (e.g. server-side or shared queries), an ExplicitException \"Criteria 'MentionedMe' is not supported here\" is thrown. The message interpolates ctx.operator.getText(), the literal operator token.","triggerScenarios":"CodeCommentQuery.parse(project, queryString, false) encountering the operator 'MentionedMe' (e.g. query text \"MentionedMe\") in a context where current-user criteria are disabled.","commonSituations":"Using a saved/shared or subscription query (which must be user-independent) that contains 'MentionedMe'; embedding a personal query into a context that forbids current-user criteria; API calls building queries on behalf of the system rather than a user.","solutions":["Remove the MentionedMe criterion from the query, or replace it with \"Mentioned(\\\"<user name>\\\")\" naming an explicit user.","Parse with withCurrentUserCriteria=true if the query is executed for an interactive, logged-in user.","Ensure the user is logged in (User.get() != null) before allowing current-user criteria.","Catch ExplicitException around parse() and show a clear message that MentionedMe is unavailable in this context."],"exampleFix":"// before\nvar query = CodeCommentQuery.parse(project, \"MentionedMe\", false); // not supported here\n// after\nvar query = CodeCommentQuery.parse(project, \"Mentioned(\\\"alice\\\")\", false); // explicit user","handlingStrategy":"validation","validationCode":"// reject current-user criteria when parsing user-independent queries\nstatic boolean usesCurrentUserCriteria(String q) {\n    return q.matches(\".*\\\\b(MentionedMe|CreatedByMe|RepliedByMe)\\\\b.*\");\n}\n// only call parse(..., withCurrentUserCriteria=true) if usesCurrentUserCriteria(q) is acceptable in this context","typeGuard":null,"tryCatchPattern":"try {\n    var query = CodeCommentQuery.parse(project, queryString, false);\n} catch (ExplicitException e) {\n    showUserError(e.getMessage()); // e.g. Criteria 'MentionedMe' is not supported here\n}","preventionTips":["Do not put MentionedMe/CreatedByMe/RepliedByMe into saved or shared queries.","Prefer explicit-user forms like Mentioned(\"alice\") in shared contexts.","Check whether the target context allows current-user criteria before building the query."],"tags":["search-query","query-parser","unsupported-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-14T05:17:10.506Z"}