{"record":{"id":"e896a9dd087c6a42","repo":"theonedev/onedev","slug":"criteria-criteriatext-is-not-supported-here","errorCode":null,"errorMessage":"Criteria '${criteriaText}' is not supported here","messagePattern":"Criteria '(.+?)' is not supported here","errorType":"validation","errorClass":"ExplicitException","httpStatus":500,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/commit/CommitQuery.java","lineNumber":76,"sourceCode":"\t\t\t\t@Override\n\t\t\t\tpublic void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,\n\t\t\t\t\t\tint charPositionInLine, String msg, RecognitionException e) {\n\t\t\t\t\tthrow new RuntimeException(\"Malformed query\", e);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\tCommonTokenStream tokens = new CommonTokenStream(lexer);\n\t\t\tCommitQueryParser parser = new CommitQueryParser(tokens);\n\t\t\tparser.removeErrorListeners();\n\t\t\tparser.setErrorHandler(new BailErrorStrategy());\n\t\t\t\n\t\t\tMap<Class<? extends CommitCriteria>, List<Object>> criteriaValues = new LinkedHashMap<>();\n\t\t\t\n\t\t\tfor (CriteriaContext criteria: parser.query().criteria()) {\n\t\t\t\tif (criteria.authorCriteria() != null) {\n\t\t\t\t\tif (criteria.authorCriteria().AuthoredByMe() != null) {\n\t\t\t\t\t\tif (!withCurrentUserCriteria)\n\t\t\t\t\t\t\tthrow new ExplicitException(\"Criteria '\" + criteria.authorCriteria().AuthoredByMe().getText() + \"' is not supported here\");\n\t\t\t\t\t\t\tcriteriaValues.computeIfAbsent(AuthorCriteria.class, k->new ArrayList<>()).add(null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (var value: criteria.authorCriteria().Value())\n\t\t\t\t\t\t\tcriteriaValues.computeIfAbsent(AuthorCriteria.class, k->new ArrayList<>()).add(getValue(value));\n\t\t\t\t\t}\n\t\t\t\t} else if (criteria.committerCriteria() != null) {\n\t\t\t\t\tif (criteria.committerCriteria().CommittedByMe() != null) {\n\t\t\t\t\t\tif (!withCurrentUserCriteria)\n\t\t\t\t\t\t\tthrow new ExplicitException(\"Criteria '\" + criteria.committerCriteria().CommittedByMe().getText() + \"' is not supported here\");\n\t\t\t\t\t\tcriteriaValues.computeIfAbsent(CommitterCriteria.class, k->new ArrayList<>()).add(null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (var value: criteria.committerCriteria().Value())\n\t\t\t\t\t\t\tcriteriaValues.computeIfAbsent(CommitterCriteria.class, k->new ArrayList<>()).add(getValue(value));\n\t\t\t\t\t}\n\t\t\t\t} else if (criteria.messageCriteria() != null) {\n\t\t\t\t\tfor (var value: criteria.messageCriteria().Value()) \n\t\t\t\t\t\tcriteriaValues.computeIfAbsent(MessageCriteria.class, k->new ArrayList<>()).add(getValue(value));\n\t\t\t\t} else if (criteria.fuzzyCriteria() != null) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/commit/CommitQuery.java#L58-L94","documentation":"CommitQuery.parse walks the parsed criteria and rejects the 'Authored by me' criterion when the query is parsed without current-user context (withCurrentUserCriteria == false), throwing ExplicitException 'Criteria <text> is not supported here'. Some contexts (e.g. queries evaluated for other users or scheduled jobs) cannot resolve 'me', so the criterion is disallowed.","triggerScenarios":"Parsing a commit query containing 'Authored by me' (AuthoredByMe token) while CommitQuery.parse is called with withCurrentUserCriteria=false — e.g. in contexts with no security context / impersonation available.","commonSituations":"Using 'Authored by me' in a commit query evaluated server-side outside a user session (webhook, scheduled report); embedding the query in a setting where current user is undefined; copy-pasting a personal query into a shared context.","solutions":["Replace 'Authored by me' with an explicit author name/value, e.g. author(\"login\").","Parse the query with withCurrentUserCriteria=true if the evaluation context does have a current user.","Catch ExplicitException to return a clear message that the criterion is unsupported in this context."],"exampleFix":"// before\nCommitQuery.parse(project, \"authored by me\", false);\n// after\nCommitQuery.parse(project, \"author(\\\"john\\\")\", false);","handlingStrategy":"validation","validationCode":"if (withCurrentUserCriteria == false && queryString.matches(\"(?i).*authored\\\\s+by\\\\s+me.*\"))\n    throw new IllegalArgumentException(\"'Authored by me' needs a current-user context\");","typeGuard":null,"tryCatchPattern":"try {\n    return CommitQuery.parse(project, q, false);\n} catch (ExplicitException e) {\n    if (e.getMessage().contains(\"not supported here\"))\n        throw new UserFriendlyException(\"Replace 'me' criteria with explicit values in this context\");\n    throw e;\n}","preventionTips":["Use explicit author names in shared/scheduled queries, never 'me'","Only pass withCurrentUserCriteria=true when a valid user session exists","Document which query contexts resolve current-user criteria"],"tags":["commit-search","parsing","user-context"],"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"}