theonedev/onedev · error · NotAcceptableException
Count should not be greater than ${MAX_COMMITS}
Error message
Count should not be greater than ${MAX_COMMITS} What it means
RepositoryResource.queryCommits caps the number of commits a single REST query may return at MAX_COMMITS. If the 'count' query parameter exceeds this server-side maximum, it throws a NotAcceptableException with message "Count should not be greater than " + MAX_COMMITS, protecting the server from unbounded history traversals.
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/RepositoryResource.java:276
return Response.ok().build();
}
@Api(order=83, description="Query commits of specified project. Will return list of matching commit hashes")
@Path("/{projectId}/commits")
@GET
public List<LogCommit> queryCommits(
@PathParam("projectId") Long projectId,
@QueryParam("query") @Api(description="Syntax of this query is the same as in commits page", example="since tag(v4.0.0) until tag(v4.7.0)") String query,
@QueryParam("count") @Api(example="100", description="Number of commits to return") int count,
@QueryParam("field") @Api(exampleProvider = "getFieldsExample", description = "Fields to return. Unspecified fields will return as null in returned commit object") List<String> fields) {
Project project = projectService.load(projectId);
if (!SecurityUtils.canReadCode(project)) {
throw new UnauthorizedException();
}
if (count > MAX_COMMITS)
throw new NotAcceptableException("Count should not be greater than " + MAX_COMMITS);
var parsedQuery = CommitQuery.parse(project, query, true);
RevListOptions options = new RevListOptions();
options.ignoreCase(true);
options.count(count);
parsedQuery.fill(project, options);
var fieldSet = EnumSet.noneOf(LogCommand.Field.class);
fieldSet.addAll(fields.stream().map(LogCommand.Field::valueOf).collect(toList()));
return gitService.log(project, options, fieldSet);
}
@Api(order=86, description="Get specified commit")
@Path("/{projectId}/commits/{commitHash}")
@GET
public LogCommit getCommit(View on GitHub (pinned to d44925c47c)
Solutions
- Reduce the count parameter to at most MAX_COMMITS (the message states the exact allowed maximum).
- Paginate: query commits in batches of the max size, advancing the query with until/commit criteria for each page.
- Narrow the query (e.g. since/until or path filters) so fewer commits need to be returned per call.
Example fix
// before GET /api/projects/42/commits?count=10000 // after GET /api/projects/42/commits?count=100&query="until commit(<last-seen-hash>)"
Defensive patterns
Strategy: validation
Validate before calling
const MAX_COMMITS = 1000; // match server limit stated in the error
if (count > MAX_COMMITS) {
count = MAX_COMMITS; // or paginate
} Prevention
- Clamp client-side page sizes to the documented MAX_COMMITS.
- Implement pagination using until/commit query criteria instead of huge counts.
- Read the NotAcceptableException message — it reports the exact server limit.
When it happens
Trigger: GET .../commits?count=N where N is greater than the server's MAX_COMMITS limit (e.g. count=100000). Any pagination logic that requests 'all commits in one call' will trip this.
Common situations: Migration/export scripts requesting huge counts; clients porting from other Git APIs without page-size limits; hardcoded large defaults in CI reporting tools.
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 ${RestConstants.MAX_PAGE_SI
- ${e.getMessage()}
- Count should not be greater than
- Count should not be greater than
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/4af866b535a7d4d0.
Report an issue: GitHub.