{"record":{"id":"acdeeb455ccddc1f","repo":"theonedev/onedev","slug":"please-login-to-perform-this-query-acdeeb","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/entity/pullrequest/IgnoredByMeCriteria.java","lineNumber":29,"sourceCode":"import org.jspecify.annotations.Nullable;\n\nimport io.onedev.server.exception.NotAcceptableException;\nimport io.onedev.server.model.PullRequest;\nimport io.onedev.server.model.User;\nimport io.onedev.server.util.ProjectScope;\nimport io.onedev.server.util.criteria.Criteria;\n\npublic class IgnoredByMeCriteria extends Criteria<PullRequest> {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\t@Override\n\tpublic Predicate getPredicate(@Nullable ProjectScope projectScope, CriteriaQuery<?> query, From<PullRequest, PullRequest> from, CriteriaBuilder builder) {\n\t\tvar user = User.get();\n\t\tif (user != null) \n\t\t\treturn getCriteria(user).getPredicate(projectScope, query, from, builder);\n\t\telse \n\t\t\tthrow new NotAcceptableException(_T(\"Please login to perform this query\"));\n\t}\n\n\t@Override\n\tpublic boolean matches(PullRequest request) {\n\t\tvar user = User.get();\n\t\tif (user != null)\n\t\t\treturn getCriteria(user).matches(request);\n\t\telse\n\t\t\tthrow new NotAcceptableException(_T(\"Please login to perform this query\"));\n\t}\n\t\n\tprivate Criteria<PullRequest> getCriteria(User user) {\n\t\treturn new IgnoredByUserCriteria(user);\n\t}\n\n\t@Override\n\tpublic String toStringWithoutParens() {\n\t\treturn PullRequestQuery.getRuleName(IgnoredByMe);","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/pullrequest/IgnoredByMeCriteria.java#L11-L47","documentation":"IgnoredByMeCriteria.getPredicate() delegates to IgnoredByUserCriteria for the current user to build a DB predicate for pull requests the user ignored. For an anonymous session User.get() is null and the criteria throws NotAcceptableException 'Please login to perform this query'.","triggerScenarios":"Running a pull request query with the 'ignored by me' criterion through the query parser/DB evaluation path without authentication.","commonSituations":"Guest users opening a shared query URL containing '~ignored by me', API integrations omitting credentials, dashboards with user-relative default queries served anonymously.","solutions":["Authenticate the request before executing the query.","Rewrite the query with an explicit username instead of 'me'.","Configure the client/dashboard to use a login-safe default query for anonymous visitors."],"exampleFix":"// before\nGET /~api/pull-requests?query=\"ignored\" is \"me\"  (no auth)\n// after\nGET /~api/pull-requests?query=\"ignored\" is \"alice\"  (or add Authorization header)","handlingStrategy":"validation","validationCode":"if (User.get() == null && query.contains(\"ignored by me\")) redirect(\"/login\");","typeGuard":"function userRequired() { return User.get() != null; }","tryCatchPattern":"try { runQuery(q); } catch (NotAcceptableException e) { if (e.getMessage().contains(\"login\")) showLoginPrompt(); else throw e; }","preventionTips":["Do not bookmark/share 'ignored by me' query URLs for guest access.","Use explicit usernames in scheduled reports.","Test queries in an incognito/guest session before publishing them."],"tags":["onedev","query","authentication","pull-request"],"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"}