theonedev/onedev · warning · NotAcceptableException
Count should not be greater than ${MAX_PAGE_SIZE}
Error message
Count should not be greater than ${MAX_PAGE_SIZE} What it means
Thrown by GET /projects (queryProjects) when a non-administrator requests more than RestConstants.MAX_PAGE_SIZE results in one page. The NotAcceptableException maps to HTTP 406 and protects the server from large unbounded queries; admins are exempt from the cap.
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/ProjectResource.java:211
@Path("/{projectId}/labels")
@GET
public Collection<ProjectLabel> getLabels(@PathParam("projectId") Long projectId) {
Project project = projectService.load(projectId);
if (!SecurityUtils.canAccessProject(project))
throw new UnauthorizedException();
return project.getLabels();
}
@Api(order=700)
@GET
public List<ProjectData> queryProjects(
@QueryParam("query") @Api(description="Syntax of this query is the same as in <a href='/~projects'>projects page</a>", example="\"Name\" is \"projectName\"") 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 = ProjectQuery.parse(query);
return projectService.query(subject, parsedQuery, false, offset, count).stream()
.map(ProjectData::from)
.collect(Collectors.toList());
}
@Api(order=750)
@Path("/{projectId}/iterations")
@GET
public List<Iteration> queryIterations(@PathParam("projectId") Long projectId, @QueryParam("name") String name,
@QueryParam("startBefore") @Api(exampleProvider="getDateExample", description="ISO 8601 date") String startBefore,
@QueryParam("startAfter") @Api(exampleProvider="getDateExample", description="ISO 8601 date") String startAfter,
@QueryParam("dueBefore") @Api(exampleProvider="getDateExample", description="ISO 8601 date") String dueBefore,
@QueryParam("dueAfter") @Api(exampleProvider="getDateExample", description="ISO 8601 date") String dueAfter,
@QueryParam("closed") Boolean closed, @QueryParam("offset") @Api(example="0") int offset,
@QueryParam("count") @Api(example="100") int count) {View on GitHub (pinned to d44925c47c)
Solutions
- Reduce the count parameter to RestConstants.MAX_PAGE_SIZE or less and iterate with offset until fewer results than count are returned.
- Use an administrator token only if a single oversized page is truly required.
- Combine offset pagination with a query filter (e.g. by name) to shrink result sets per page.
- Check the API docs / RestConstants for the exact current page size limit on your OneDev version.
Example fix
// before GET /~api/projects?offset=0&count=1000 // 406 // after: paginate GET /~api/projects?offset=0&count=100 GET /~api/projects?offset=100&count=100 // ... until short page
Defensive patterns
Strategy: validation
Validate before calling
const MAX_PAGE_SIZE = 100; // keep in sync with RestConstants.MAX_PAGE_SIZE
async function queryAllProjects(query = '') {
const out = [];
for (let offset = 0; ; offset += MAX_PAGE_SIZE) {
const page = await api.get(`/~api/projects?query=${encodeURIComponent(query)}&offset=${offset}&count=${MAX_PAGE_SIZE}`);
out.push(...page);
if (page.length < MAX_PAGE_SIZE) return out;
}
} Try / catch
try {
const projects = await api.get(`/~api/projects?count=${count}`);
} catch (e) {
if (e.status === 406) {
// count exceeded MAX_PAGE_SIZE — clamp and paginate instead
} else throw e;
} Prevention
- Always clamp count to the documented MAX_PAGE_SIZE before calling.
- Implement offset-based pagination loops in export scripts by default.
- Do not copy oversized queries from admin sessions to normal-user tokens.
- Filter with the query parameter to reduce per-page result sizes.
When it happens
Trigger: Calling GET /~api/projects?count=1000 (or any count > MAX_PAGE_SIZE, typically 100?) with a non-admin token, or omitting count defaults is fine but explicitly passing a large count triggers it.
Common situations: Bulk-sync scripts exporting all projects in one call; copying a query from an admin's session to a normal user's token; assuming no pagination limit exists.
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 ${RestConstants.MAX_PAGE_SI
- Count should not be greater than
- Unexpected query params:
- Missing query params:
- Count should not be greater than 1000
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/d8051aaf39e04215.
Report an issue: GitHub.