{"record":{"id":"dafaf68ef55ed7be","repo":"theonedev/onedev","slug":"please-login-to-perform-this-query","errorCode":null,"errorMessage":"Please login to perform this query","messagePattern":"Please login to perform this query","errorType":"http","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/commit/PersonCriteria.java","lineNumber":55,"sourceCode":"\tprivate boolean matches(String value, PersonIdent person) {\n\t\tString formatted = String.format(\"%s <%s>\", person.getName(), person.getEmailAddress());\n\t\treturn WildcardUtils.matchString(value, formatted);\n\t}\n\n\tprivate static UserService getUserService() {\n\t\treturn OneDev.getInstance(UserService.class);\n\t}\n\t\n\tprotected void fill(Project project, List<String> persons) {\n\t\tfor (String value: values) {\n\t\t\tif (value == null) { // authored by me\n\t\t\t\tUser user = SecurityUtils.getUser();\n\t\t\t\tif (user != null) {\n\t\t\t\t\tuser.getVerifiedEmailAddresses().forEach(it-> {\n\t\t\t\t\t\tpersons.add(\"<\" + it + \">\");\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthrow new NotAcceptableException(_T(\"Please login to perform this query\"));\n\t\t\t\t}\n\t\t\t} else if (value.startsWith(\"@\")) {\n\t\t\t\tString userName = value.substring(1);\n\t\t\t\tUser user = getUserService().findByName(userName);\n\t\t\t\tif (user != null) {\n\t\t\t\t\tfor (String emailAddress: user.getVerifiedEmailAddresses()) {\n\t\t\t\t\t\tpersons.add(\"<\" + emailAddress + \">\");\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpersons.add(Strings.CS.replace(value, \"*\", \".*\"));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpersons.add(Strings.CS.replace(value, \"*\", \".*\"));\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected boolean matches(PersonIdent person) {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/commit/PersonCriteria.java#L37-L73","documentation":"PersonCriteria parses query values like '@me' or anonymous persons; when the query uses the current-user-dependent value but no one is authenticated, the criteria cannot resolve verified email addresses, so it throws a NotAcceptableException with a localized 'Please login to perform this query' message.","triggerScenarios":"Calling QueryContext/commit-query parsing or evaluation with a person value requiring SecurityUtils.getUser() (e.g. value starting with '~'/anonymous-to-me) while the request has no authenticated user session (anonymous access, REST call without auth token, or cron/API context without login).","commonSituations":"Hitting a saved query URL in an incognito browser; calling the commit query REST API without an authentication header; embedded query execution in a build/CI script where SecurityUtils.getUser() returns null.","solutions":["Log in to OneDev in the current session before running the query","Add an authentication token/credential to the REST/API call (Authorization header or basic auth)","Rewrite the query to use an explicit '@username' or email value instead of the current-user value","Wrap the call in try-catch for NotAcceptableException and redirect to login"],"exampleFix":"// before\nrestClient.queryCommits(\"server\", \"~me\") // anonymous\n// after\nrestClient.queryCommits(\"server\", \"@john\") // or authenticate the request first","handlingStrategy":"try-catch","validationCode":"// before running query\nif (SecurityUtils.getUser() == null) { throw new IllegalStateException(\"login required for this query\"); }","typeGuard":null,"tryCatchPattern":"try { criteria.matches(ident); } catch (NotAcceptableException e) { redirectToLogin(); }","preventionTips":["Never run user-relative queries ('~') in anonymous or service contexts","Attach API tokens to all automated requests","Prefer explicit usernames over current-user criteria in stored queries"],"tags":["authentication","search-query","onedev"],"backgroundTag":"authentication-required","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"}