theonedev/onedev · error · NotAcceptableException
Count should not be greater than
Error message
Count should not be greater than
What it means
GET /query-pull-requests validates the paging parameter against RestConstants.MAX_PAGE_SIZE and throws NotAcceptableException ('Count should not be greater than N') when the requested count exceeds the server maximum. This caps result-page size to protect the server.
Source
Thrown at server-core/src/main/java/io/onedev/server/ai/TodResource.java:803
@Path("/query-pull-requests")
@GET
public List<Map<String, Object>> queryPullRequests(
@QueryParam("currentProject") @NotNull String currentProjectPath,
@QueryParam("project") String projectPath,
@QueryParam("query") String query,
@QueryParam("offset") int offset,
@QueryParam("count") int count) {
var subject = SecurityUtils.getSubject();
if (SecurityUtils.getUser(subject) == null)
throw new UnauthenticatedException();
var projectContext = getProjectContext(projectPath, currentProjectPath);
if (!SecurityUtils.canReadCode(projectContext.project))
throw new UnauthorizedException("Code read permission required to query pull requests");
if (count > RestConstants.MAX_PAGE_SIZE)
throw new NotAcceptableException("Count should not be greater than " + RestConstants.MAX_PAGE_SIZE);
EntityQuery<PullRequest> parsedQuery;
if (query != null)
parsedQuery = PullRequestQuery.parse(projectContext.project, query, true);
else
parsedQuery = new PullRequestQuery();
var summaries = new ArrayList<Map<String, Object>>();
for (var pullRequest : pullRequestService.query(subject, projectContext.project, parsedQuery, false, offset, count)) {
var summary = PullRequestHelper.getSummary(projectContext.currentProject, pullRequest, false);
summary.put("link", urlService.urlFor(pullRequest, true));
summaries.add(summary);
}
return summaries;
}
@Path("/query-builds")
@GETView on GitHub (pinned to d44925c47c)
Solutions
- Lower the count query parameter to RestConstants.MAX_PAGE_SIZE or below (default 100)
- Paginate: repeat calls increasing offset by count until fewer than count results are returned
- Narrow the 'query' filter so fewer results are needed per page
Example fix
// before GET /~api/tod/query-pull-requests?currentProject=app&count=5000 // after GET /~api/tod/query-pull-requests?currentProject=app&count=100&offset=0 // then offset=100, ...
Defensive patterns
Strategy: validation
Validate before calling
const MAX_PAGE_SIZE = 100; if (count > MAX_PAGE_SIZE) throw new Error(`count must be <= ${MAX_PAGE_SIZE}, got ${count}`); Try / catch
try { await queryPullRequests({...params, count}); } catch (e) { if (/count should not be greater/i.test(e.message)) return paginate(0, MAX_PAGE_SIZE); throw e; } Prevention
- Cap page size at the server's MAX_PAGE_SIZE constant
- Implement offset-based pagination loops instead of large single requests
- Read the error message: it includes the exact allowed maximum
When it happens
Trigger: Calling query-pull-requests with ?count= set above RestConstants.MAX_PAGE_SIZE (e.g. 1000).
Common situations: AI agents or scripts requesting 'all' results in one call; copy-pasted client code with a large default page size; paginating incorrectly instead of using offset+count loops.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Count should not be greater than ${RestConstants.MAX_PAGE_SI
- Count should not be greater than 1000
- Count should not be greater than ${MAX_PAGE_SIZE}
- Count should not be greater than 100
- Unexpected query params:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/f99fc61a15306ffd.
Report an issue: GitHub.