theonedev/onedev · error · NotAcceptableException
Count should not be greater than 1000
Error message
Count should not be greater than 1000
What it means
OneDev's REST endpoint GET /builds (queryBuilds) throws NotAcceptableException with 'Count should not be greater than 1000' when a non-administrator caller passes a count parameter exceeding RestConstants.MAX_PAGE_SIZE (1000). Administrators bypass the cap. This is a server-side pagination guard to protect the API from very large page requests.
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/BuildResource.java:135
@Path("/{buildId}/fixed-issue-ids")
@GET
public Collection<Long> getFixedIssueIds(@PathParam("buildId") Long buildId) {
Build build = buildService.load(buildId);
if (!SecurityUtils.canAccessProject(build.getProject()))
throw new UnauthorizedException();
return build.getFixedIssueIds();
}
@Api(order=600)
@GET
public List<Build> queryBuilds(
@QueryParam("query") @Api(description="Syntax of this query is the same as in <a href='/~builds'>builds page</a>", example="\"Job\" is \"Release\"") String query,
@QueryParam("offset") @Api(example="0") int offset,
@QueryParam("count") @Api(example="100") int count) {
var subject = SecurityUtils.getSubject();
if (!SecurityUtils.isAdministrator(subject) && count > RestConstants.MAX_PAGE_SIZE)
throw new NotAcceptableException("Count should not be greater than " + RestConstants.MAX_PAGE_SIZE);
var parsedQuery = BuildQuery.parse(null, query, true, true);
return buildService.query(subject, null, parsedQuery, false, offset, count);
}
@Api(order = 650)
@Path("/{buildId}/description")
@POST
public Response setDescription(@PathParam("buildId") Long buildId, String description) {
Build build = buildService.load(buildId);
if (!SecurityUtils.canManageBuild(build))
throw new UnauthorizedException();
var oldDescription = build.getDescription();
if (!Objects.equals(oldDescription, description)) {
build.setDescription(description);
buildService.update(build);
auditService.audit(build.getProject(), "updated description of build \"" + build.getReference().toString(build.getProject()) + "\" via RESTful API", oldDescription, description);View on GitHub (pinned to d44925c47c)
Solutions
- Reduce the count parameter to 1000 or less and paginate with offset (count=1000, offset=0, then offset=1000, ...)
- Use an administrator account/token if you truly need pages larger than 1000
- Loop with increasing offsets until fewer than `count` results are returned
Example fix
// before GET /~api/builds?count=5000&offset=0 // after GET /~api/builds?count=1000&offset=0 GET /~api/builds?count=1000&offset=1000 // repeat until empty page
Defensive patterns
Strategy: validation
Validate before calling
const MAX_PAGE_SIZE = 1000;
function validatePage(count, offset = 0) {
if (!Number.isInteger(count) || count < 1 || count > MAX_PAGE_SIZE)
throw new Error(`count must be 1..${MAX_PAGE_SIZE} for non-admin users`);
if (offset < 0) throw new Error('offset must be >= 0');
return {count, offset};
} Prevention
- Cap client-side page size at 1000 (RestConstants.MAX_PAGE_SIZE)
- Paginate with offset instead of requesting huge pages
- Request larger pages only when running under an administrator token
When it happens
Trigger: GET /~api/builds?count=2000 (or any count > 1000) called by a non-admin user/token. Counts of 1000 or less succeed regardless of who calls.
Common situations: Scripts that hardcode large page sizes assuming unlimited paging; migrating scripts from other APIs with permissive limits; copying example requests that used admin accounts.
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 ${MAX_PAGE_SIZE}
- Count should not be greater than 100
- Count should not be greater than ${RestConstants.MAX_PAGE_SI
- Count should not be greater than
- Error parsing query
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/bdc757c0592c63ea.
Report an issue: GitHub.