theonedev/onedev · error · NotAcceptableException
Count should not be greater than
Error message
Count should not be greater than
What it means
queryTokens enforces the platform-wide REST page-size limit: if the 'count' query parameter exceeds RestConstants.MAX_PAGE_SIZE, it throws NotAcceptableException with 'Count should not be greater than <MAX_PAGE_SIZE>'. This caps result payloads on list endpoints.
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/AgentTokenResource.java:79
@Path("/{tokenId}/agent")
@GET
public Agent getAgent(@PathParam("tokenId") Long tokenId) {
if (!SecurityUtils.isAdministrator())
throw new UnauthorizedException();
AgentToken token = tokenService.load(tokenId);
return agentService.findByToken(token);
}
@Api(order=200)
@GET
public List<AgentToken> queryTokens(@QueryParam("value") String value,
@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<AgentToken> criteria = EntityCriteria.of(AgentToken.class);
if (value != null)
criteria.add(Restrictions.eq(AgentToken.PROP_VALUE, value));
return tokenService.query(criteria, offset, count);
}
@Api(order=500, description="Create new token")
@POST
public Long createToken() {
if (!SecurityUtils.isAdministrator())
throw new UnauthorizedException();
AgentToken token = new AgentToken();
tokenService.createOrUpdate(token);
auditService.audit(null, "created agent token via RESTful API", null, null);
return token.getId();View on GitHub (pinned to d44925c47c)
Solutions
- Set count to RestConstants.MAX_PAGE_SIZE or less (e.g. count=100) and paginate using offset
- Loop: request pages of count=100 incrementing offset until a page returns fewer results than requested
- Filter with the value parameter to shrink the result set instead of fetching everything
Example fix
// before GET /~api/agent-tokens?offset=0&count=10000 // after GET /~api/agent-tokens?offset=0&count=100 GET /~api/agent-tokens?offset=100&count=100 // ...repeat until short page
Defensive patterns
Strategy: validation
Validate before calling
final int MAX_PAGE_SIZE = 100; // RestConstants.MAX_PAGE_SIZE if (count > MAX_PAGE_SIZE) count = MAX_PAGE_SIZE; // clamp before calling
Type guard
int safeCount(int c) { return Math.min(c, 100); } Try / catch
try { client.queryAgentTokens(value, offset, count); } catch (ClientErrorException e) { if (e.getResponse().getStatus() == 406) retryWithCount(offset, 100); } Prevention
- Always clamp count to RestConstants.MAX_PAGE_SIZE
- Paginate with offset loops instead of large counts
- Centralize page-size constants in API client code
When it happens
Trigger: GET /~api/agent-tokens?count=1000 (admin caller) where 1000 > RestConstants.MAX_PAGE_SIZE (typically 100).
Common situations: Bulk-export scripts requesting 'all' tokens with a huge count; copying a large limit from another API; off-by-order-of-magnitude pagination settings.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
- Count should not be greater than
- Not authorized
- Count should not be greater than
- Count should not be greater than ${MAX_COMMITS}
- Count should not be greater than ${RestConstants.MAX_PAGE_SI
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/96cbd94c737c36f1.
Report an issue: GitHub.