{"record":{"id":"aca295905d030521","repo":"theonedev/onedev","slug":"please-login-to-perform-this-query-aca295","errorCode":null,"errorMessage":"Please login to perform this query","messagePattern":"Please login to perform this query","errorType":"exception","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/search/entity/issue/IgnoredByMeCriteria.java","lineNumber":29,"sourceCode":"import org.jspecify.annotations.Nullable;\n\nimport io.onedev.server.exception.NotAcceptableException;\nimport io.onedev.server.model.Issue;\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<Issue> {\n\n\tprivate static final long serialVersionUID = 1L;\n\n\t@Override\n\tpublic Predicate getPredicate(@Nullable ProjectScope projectScope, CriteriaQuery<?> query, From<Issue, Issue> 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(Issue issue) {\n\t\tvar user = User.get();\n\t\tif (user != null)\n\t\t\treturn getCriteria(user).matches(issue);\n\t\telse\n\t\t\tthrow new NotAcceptableException(_T(\"Please login to perform this query\"));\n\t}\n\t\n\tprivate Criteria<Issue> getCriteria(User user) {\n\t\treturn new IgnoredByUserCriteria(user);\n\t}\n\n\t@Override\n\tpublic String toStringWithoutParens() {\n\t\treturn IssueQuery.getRuleName(IgnoredByMe);","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/search/entity/issue/IgnoredByMeCriteria.java#L11-L47","documentation":"IgnoredByMeCriteria builds a query predicate (or in-memory match) for issues ignored by the current user. It resolves the user from the request context via User.get(); when no user is bound to the thread (anonymous access, or execution outside an authenticated request), it refuses and throws NotAcceptableException with 'Please login to perform this query'. The 'IgnoredByMe' concept is inherently user-relative, so anonymous evaluation is impossible.","triggerScenarios":"Calling IssueQuery.find/optimize or getPredicate on a query containing 'IgnoredByMe' while the current session is anonymous (no login), or invoking the criteria from background/system code where no User is set on the thread.","commonSituations":"Anonymous users hitting a saved query or dashboard containing 'IgnoredByMe'; REST API calls without authentication; scheduled jobs or webhooks evaluating issue queries server-side with no user context.","solutions":["Log in (or authenticate the API request) so User.get() returns a real user before running the query","Remove 'IgnoredByMe' from queries that anonymous users can execute, or use an explicit user criteria like 'IgnoredBy \"name\"' via IgnoredByUserCriteria","For server-side code, run the query within an authenticated user context instead of a bare thread"],"exampleFix":"// before (anonymous)\nIssueQuery.parse(project, \"IgnoredByMe\").find(...);\n// after: ensure authenticated or use explicit user criteria\nnew IgnoredByUserCriteria(currentUser).getPredicate(scope, query, from, builder);","handlingStrategy":"validation","validationCode":"if (User.get() == null) {\n    // block user-relative criteria before running the query\n    throw new NotAcceptableException(\"Login required for this query\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check User.get() before executing queries containing 'IgnoredByMe' or other *Me criteria","Require authentication for endpoints that accept user-supplied queries","Prefer explicit-user criteria in server-side/background contexts"],"tags":["query","authentication","search-criteria"],"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"}