theonedev/onedev · warning · NotAcceptableException

Count should not be greater than ${RestConstants.MAX_PAGE_SI

Error message

Count should not be greater than ${RestConstants.MAX_PAGE_SIZE}

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/rest/resource/RoleResource.java:69

	@Api(order=100)
	@Path("/{roleId}")
    @GET
    public Role getRole(@PathParam("roleId") Long roleId) {
    	if (!SecurityUtils.isAdministrator()) 
			throw new UnauthorizedException();
    	return roleService.load(roleId);
    }	

	@Api(order=200)
	@GET
    public List<Role> queryRoles(@QueryParam("name") String name, @QueryParam("offset") @Api(example="0") int offset, 
    		@QueryParam("count") @Api(example="100") int count) {
		
		if (!SecurityUtils.isAdministrator())
			throw new UnauthorizedException();
		
    	if (count > RestConstants.MAX_PAGE_SIZE)
    		throw new NotAcceptableException("Count should not be greater than " + RestConstants.MAX_PAGE_SIZE);

		EntityCriteria<Role> criteria = EntityCriteria.of(Role.class);
		if (name != null) 
			criteria.add(Restrictions.ilike("name", name.replace('*', '%'), MatchMode.EXACT));
		
    	return roleService.query(name, offset, count);
    }

	@Api(order=250)
	@Path("/ids/{name}")
	@GET
	public Long getRoleId(@PathParam("name") String name) {
		if (SecurityUtils.getAuthUser() == null)
			throw new UnauthenticatedException();

		var role = roleService.find(name);
		if (role != null)
			return role.getId();

View on GitHub (pinned to d44925c47c)

Solutions

  1. Lower the count parameter to at most RestConstants.MAX_PAGE_SIZE
  2. Paginate using offset plus a page-size within the limit
  3. Query the server's configured max page size before issuing requests

Example fix

// before
GET /api/roles?count=50000
// after
GET /api/roles?offset=0&count=100
Defensive patterns

Strategy: validation

Validate before calling

if (count > MAX_PAGE_SIZE) count = MAX_PAGE_SIZE; // then paginate with offset

Prevention

When it happens

Trigger: Calling GET /roles with a count query parameter greater than the server's maximum page size (e.g. count=100000).

Common situations: Clients requesting 'all rows at once' instead of paginating; copied code using an oversized default page size.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/4cee534524b5fcff. Report an issue: GitHub.