theonedev/onedev · error · NotAcceptableException
Count should not be greater than
Error message
Count should not be greater than
What it means
WorkspaceResource.queryWorkspaces enforces a maximum page size (RestConstants.MAX_PAGE_SIZE) for non-administrator subjects. Requesting more workspaces per page than the limit throws NotAcceptableException with the max value in the message. This protects the server from expensive unbounded queries by ordinary users.
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/WorkspaceResource.java:91
@Api(order=100)
@Path("/{workspaceId}")
@GET
public Workspace getWorkspace(@PathParam("workspaceId") Long workspaceId) {
Workspace workspace = workspaceService.load(workspaceId);
if (!SecurityUtils.canCreateWorkspaces(workspace.getProject()))
throw new UnauthorizedException();
return workspace;
}
@Api(order=200)
@GET
public List<Workspace> queryWorkspaces(
@QueryParam("query") @Api(description="Syntax of this query is the same as in <a href='/~workspaces'>workspaces page</a>", example="active") 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 = WorkspaceQuery.parse(null, query, true);
return workspaceService.query(subject, null, parsedQuery, offset, count);
}
@Api(order=300, description="Create new workspace")
@POST
public Long createWorkspace(@NotNull @Valid WorkspaceCreateData data) {
var subject = SecurityUtils.getSubject();
var user = SecurityUtils.getUser(subject);
if (user == null)
throw new UnauthorizedException();
Project project = projectService.load(data.getProjectId());
if (!SecurityUtils.canCreateWorkspaces(subject, project))
throw new UnauthorizedException();
View on GitHub (pinned to d44925c47c)
Solutions
- Reduce the count parameter to RestConstants.MAX_PAGE_SIZE or less
- Paginate with offset/count loops until fewer results than the page size are returned
- Authenticate as an administrator if a larger single page is genuinely required
Example fix
// before
list = get("/workspaces?offset=0&count=10000");
// after
do { list = get("/workspaces?offset=" + offset + "&count=100"); offset += list.size(); } while (list.size() == 100); Defensive patterns
Strategy: validation
Validate before calling
if (!isAdmin && count > MAX_PAGE_SIZE) count = MAX_PAGE_SIZE;
Try / catch
try { queryWorkspaces(q, offset, count); } catch (NotAcceptableException e) { log.warn("page size too large, retrying with {}"); queryWorkspaces(q, offset, MAX_PAGE_SIZE); } Prevention
- Clamp count to the documented MAX_PAGE_SIZE
- Implement offset-based pagination instead of huge pages
- Query as admin only when a full snapshot is unavoidable
When it happens
Trigger: GET /workspaces?count=N with N greater than RestConstants.MAX_PAGE_SIZE while authenticated as a non-admin user.
Common situations: Client scripts hardcoding a large count (e.g. 10000) to 'fetch everything'; pagination code copied from an admin-only script.
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
- Count should not be greater than
- Count should not be greater than ${MAX_COMMITS}
- Count should not be greater than ${RestConstants.MAX_PAGE_SI
- 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/3e48cee98e44bd8d.
Report an issue: GitHub.