{"record":{"id":"4cee534524b5fcff","repo":"theonedev/onedev","slug":"count-should-not-be-greater-than-restconstants-m-4cee53","errorCode":null,"errorMessage":"Count should not be greater than ${RestConstants.MAX_PAGE_SIZE}","messagePattern":"Count should not be greater than (.+?)","errorType":"http","errorClass":"NotAcceptableException","httpStatus":406,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/rest/resource/RoleResource.java","lineNumber":69,"sourceCode":"\t@Api(order=100)\n\t@Path(\"/{roleId}\")\n    @GET\n    public Role getRole(@PathParam(\"roleId\") Long roleId) {\n    \tif (!SecurityUtils.isAdministrator()) \n\t\t\tthrow new UnauthorizedException();\n    \treturn roleService.load(roleId);\n    }\t\n\n\t@Api(order=200)\n\t@GET\n    public List<Role> queryRoles(@QueryParam(\"name\") String name, @QueryParam(\"offset\") @Api(example=\"0\") int offset, \n    \t\t@QueryParam(\"count\") @Api(example=\"100\") int count) {\n\t\t\n\t\tif (!SecurityUtils.isAdministrator())\n\t\t\tthrow new UnauthorizedException();\n\t\t\n    \tif (count > RestConstants.MAX_PAGE_SIZE)\n    \t\tthrow new NotAcceptableException(\"Count should not be greater than \" + RestConstants.MAX_PAGE_SIZE);\n\n\t\tEntityCriteria<Role> criteria = EntityCriteria.of(Role.class);\n\t\tif (name != null) \n\t\t\tcriteria.add(Restrictions.ilike(\"name\", name.replace('*', '%'), MatchMode.EXACT));\n\t\t\n    \treturn roleService.query(name, offset, count);\n    }\n\n\t@Api(order=250)\n\t@Path(\"/ids/{name}\")\n\t@GET\n\tpublic Long getRoleId(@PathParam(\"name\") String name) {\n\t\tif (SecurityUtils.getAuthUser() == null)\n\t\t\tthrow new UnauthenticatedException();\n\n\t\tvar role = roleService.find(name);\n\t\tif (role != null)\n\t\t\treturn role.getId();","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/rest/resource/RoleResource.java#L51-L87","documentation":"Pagination guard in RoleResource.queryRoles: the requested page size exceeds RestConstants.MAX_PAGE_SIZE, which caps query results to protect the server; NotAcceptableException is thrown. Fix: request count <= MAX_PAGE_SIZE and paginate with offset.","triggerScenarios":"Calling GET /roles with a count query parameter greater than the server's maximum page size (e.g. count=100000).","commonSituations":"Clients requesting 'all rows at once' instead of paginating; copied code using an oversized default page size.","solutions":["Lower the count parameter to at most RestConstants.MAX_PAGE_SIZE","Paginate using offset plus a page-size within the limit","Query the server's configured max page size before issuing requests"],"exampleFix":"// before\nGET /api/roles?count=50000\n// after\nGET /api/roles?offset=0&count=100","handlingStrategy":"validation","validationCode":"if (count > MAX_PAGE_SIZE) count = MAX_PAGE_SIZE; // then paginate with offset","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap count at the server's MAX_PAGE_SIZE","Paginate with offset instead of very large counts","Reuse a shared pagination helper across REST calls"],"tags":["rest-api","pagination","validation"],"backgroundTag":"argument-out-of-range","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"}