theonedev/onedev · error · NotAcceptableException

Count should not be greater than

Error message

Count should not be greater than 

What it means

GET /issues query endpoint limits the page size: non-administrator subjects may not request more than RestConstants.MAX_PAGE_SIZE issues per call. Exceeding it throws NotAcceptableException with message "Count should not be greater than " + MAX_PAGE_SIZE (default max is 100 in OneDev). Use offset-based paging instead of one huge request.

Source

Thrown at server-core/src/main/java/io/onedev/server/rest/resource/IssueResource.java:277

    		FixCommit issueCommit = new FixCommit();
    		issueCommit.setProjectId(commit.getProject().getId());
    		issueCommit.setCommitHash(commit.getCommitId().name());
    		issueCommits.add(issueCommit);
    	}
    	return issueCommits;
    }
	
	@Api(order=900, exampleProvider = "getIssuesExample")
	@GET
    public List<Map<String, Object>> queryIssues(
    		@QueryParam("query") @Api(description="Syntax of this query is the same as in <a href='/~issues'>issues page</a>", example="\"State\" is \"Open\"") String query,
			@QueryParam("withFields") @Api(description = "Whether or not to include issue fields. Default to false", example="true") Boolean withFields, 
    		@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);

		IssueQueryParseOption option = new IssueQueryParseOption().withCurrentUserCriteria(true);
		var parsedQuery = IssueQuery.parse(null, query, option, true);

		var issues = new ArrayList<Map<String, Object>>();
		for (var issue: issueService.query(subject, null, parsedQuery, false, offset, count)) {
			var issueMap = getIssueMap(subject, issue);
			if (withFields != null && withFields)
				issueMap.put("fields", issue.getFields());
			issues.add(issueMap);
		}
		
		return issues;
    }
	
	@SuppressWarnings("unused")
	private static Map<String, Object> getIssueExample() {
		var issueMap = ApiHelpUtils.getExampleMap(Issue.class, ValueInfo.Origin.READ_BODY);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Reduce the count query parameter to RestConstants.MAX_PAGE_SIZE (100) or less.
  2. Paginate: keep count at the max and advance offset until fewer results than count are returned.
  3. Use an administrator token if you legitimately need larger pages.
  4. Fix your client's page-size constant to match the server's RestConstants.MAX_PAGE_SIZE.

Example fix

// before
GET /~api/issues?count=1000&offset=0
// after: paginate
for (int offset = 0; ; offset += 100) {
    var page = client.queryIssues(query, null, 100, offset); // count <= 100
    if (page.isEmpty()) break;
}
Defensive patterns

Strategy: validation

Validate before calling

// clamp count to the server max and paginate
final int MAX_PAGE = 100; // RestConstants.MAX_PAGE_SIZE
int safeCount = Math.min(requestedCount, MAX_PAGE);
GET "/~api/issues?count=" + safeCount + "&offset=" + offset;

Try / catch

try { return client.queryIssues(query, withFields, count, offset); }
catch (NotAcceptableException e) { /* count too large: retry with 100 and paginate */ return pagedQuery(query, 100, offset); }

Prevention

When it happens

Trigger: GET /~api/issues?count=500 (or any count > RestConstants.MAX_PAGE_SIZE, typically 100) with a non-admin token; queryMissingIssues-style syncs configured with too-large page sizes.

Common situations: Bulk exporters syncing all issues with count=1000; migration scripts copying tool defaults (e.g. 500) into the count parameter; assuming admin-only endpoints allow unlimited pages.

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


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/e3c8322dda98f42c. Report an issue: GitHub.