{"record":{"id":"e3c8322dda98f42c","repo":"theonedev/onedev","slug":"count-should-not-be-greater-than-e3c832","errorCode":null,"errorMessage":"Count should not be greater than ","messagePattern":"Count should not be greater than ","errorType":"http","errorClass":"NotAcceptableException","httpStatus":406,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/rest/resource/IssueResource.java","lineNumber":277,"sourceCode":"    \t\tFixCommit issueCommit = new FixCommit();\n    \t\tissueCommit.setProjectId(commit.getProject().getId());\n    \t\tissueCommit.setCommitHash(commit.getCommitId().name());\n    \t\tissueCommits.add(issueCommit);\n    \t}\n    \treturn issueCommits;\n    }\n\t\n\t@Api(order=900, exampleProvider = \"getIssuesExample\")\n\t@GET\n    public List<Map<String, Object>> queryIssues(\n    \t\t@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,\n\t\t\t@QueryParam(\"withFields\") @Api(description = \"Whether or not to include issue fields. Default to false\", example=\"true\") Boolean withFields, \n    \t\t@QueryParam(\"offset\") @Api(example=\"0\") int offset, \n    \t\t@QueryParam(\"count\") @Api(example=\"100\") int count) {\n\t\t\n\t\tvar subject = SecurityUtils.getSubject();\n    \tif (!SecurityUtils.isAdministrator(subject) && count > RestConstants.MAX_PAGE_SIZE)\n    \t\tthrow new NotAcceptableException(\"Count should not be greater than \" + RestConstants.MAX_PAGE_SIZE);\n\n\t\tIssueQueryParseOption option = new IssueQueryParseOption().withCurrentUserCriteria(true);\n\t\tvar parsedQuery = IssueQuery.parse(null, query, option, true);\n\n\t\tvar issues = new ArrayList<Map<String, Object>>();\n\t\tfor (var issue: issueService.query(subject, null, parsedQuery, false, offset, count)) {\n\t\t\tvar issueMap = getIssueMap(subject, issue);\n\t\t\tif (withFields != null && withFields)\n\t\t\t\tissueMap.put(\"fields\", issue.getFields());\n\t\t\tissues.add(issueMap);\n\t\t}\n\t\t\n\t\treturn issues;\n    }\n\t\n\t@SuppressWarnings(\"unused\")\n\tprivate static Map<String, Object> getIssueExample() {\n\t\tvar issueMap = ApiHelpUtils.getExampleMap(Issue.class, ValueInfo.Origin.READ_BODY);","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/rest/resource/IssueResource.java#L259-L295","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reduce the count query parameter to RestConstants.MAX_PAGE_SIZE (100) or less.","Paginate: keep count at the max and advance offset until fewer results than count are returned.","Use an administrator token if you legitimately need larger pages.","Fix your client's page-size constant to match the server's RestConstants.MAX_PAGE_SIZE."],"exampleFix":"// before\nGET /~api/issues?count=1000&offset=0\n// after: paginate\nfor (int offset = 0; ; offset += 100) {\n    var page = client.queryIssues(query, null, 100, offset); // count <= 100\n    if (page.isEmpty()) break;\n}","handlingStrategy":"validation","validationCode":"// clamp count to the server max and paginate\nfinal int MAX_PAGE = 100; // RestConstants.MAX_PAGE_SIZE\nint safeCount = Math.min(requestedCount, MAX_PAGE);\nGET \"/~api/issues?count=\" + safeCount + \"&offset=\" + offset;","typeGuard":null,"tryCatchPattern":"try { return client.queryIssues(query, withFields, count, offset); }\ncatch (NotAcceptableException e) { /* count too large: retry with 100 and paginate */ return pagedQuery(query, 100, offset); }","preventionTips":["Never hardcode page sizes above 100 for OneDev issue queries.","Implement generic offset pagination in your sync/export tooling.","Align page-size constants with RestConstants.MAX_PAGE_SIZE when upgrading versions."],"tags":["rest-api","pagination","page-size-limit"],"backgroundTag":"invalid-query-parameter","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}