{"record":{"id":"f99fc61a15306ffd","repo":"theonedev/onedev","slug":"count-should-not-be-greater-than","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/ai/TodResource.java","lineNumber":803,"sourceCode":"    @Path(\"/query-pull-requests\")\n    @GET\n    public List<Map<String, Object>> queryPullRequests(\n                @QueryParam(\"currentProject\") @NotNull String currentProjectPath, \n                @QueryParam(\"project\") String projectPath, \n                @QueryParam(\"query\") String query, \n                @QueryParam(\"offset\") int offset, \n                @QueryParam(\"count\") int count) {\n        var subject = SecurityUtils.getSubject();\n        if (SecurityUtils.getUser(subject) == null)\n            throw new UnauthenticatedException();\n\n        var projectContext = getProjectContext(projectPath, currentProjectPath);\n\n        if (!SecurityUtils.canReadCode(projectContext.project))\n            throw new UnauthorizedException(\"Code read permission required to query pull requests\");\n\n        if (count > RestConstants.MAX_PAGE_SIZE)\n            throw new NotAcceptableException(\"Count should not be greater than \" + RestConstants.MAX_PAGE_SIZE);\n\n        EntityQuery<PullRequest> parsedQuery;\n        if (query != null) \n            parsedQuery = PullRequestQuery.parse(projectContext.project, query, true);\n        else\n            parsedQuery = new PullRequestQuery();\n\n        var summaries = new ArrayList<Map<String, Object>>();\n        for (var pullRequest : pullRequestService.query(subject, projectContext.project, parsedQuery, false, offset, count)) {\n            var summary = PullRequestHelper.getSummary(projectContext.currentProject, pullRequest, false);\n            summary.put(\"link\", urlService.urlFor(pullRequest, true));\n            summaries.add(summary);\n        }\n        return summaries;\n    }\n\n    @Path(\"/query-builds\")\n    @GET","sourceCodeStart":785,"sourceCodeEnd":821,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L785-L821","documentation":"GET /query-pull-requests validates the paging parameter against RestConstants.MAX_PAGE_SIZE and throws NotAcceptableException ('Count should not be greater than N') when the requested count exceeds the server maximum. This caps result-page size to protect the server.","triggerScenarios":"Calling query-pull-requests with ?count= set above RestConstants.MAX_PAGE_SIZE (e.g. 1000).","commonSituations":"AI agents or scripts requesting 'all' results in one call; copy-pasted client code with a large default page size; paginating incorrectly instead of using offset+count loops.","solutions":["Lower the count query parameter to RestConstants.MAX_PAGE_SIZE or below (default 100)","Paginate: repeat calls increasing offset by count until fewer than count results are returned","Narrow the 'query' filter so fewer results are needed per page"],"exampleFix":"// before\nGET /~api/tod/query-pull-requests?currentProject=app&count=5000\n// after\nGET /~api/tod/query-pull-requests?currentProject=app&count=100&offset=0  // then offset=100, ...","handlingStrategy":"validation","validationCode":"const MAX_PAGE_SIZE = 100; if (count > MAX_PAGE_SIZE) throw new Error(`count must be <= ${MAX_PAGE_SIZE}, got ${count}`);","typeGuard":null,"tryCatchPattern":"try { await queryPullRequests({...params, count}); } catch (e) { if (/count should not be greater/i.test(e.message)) return paginate(0, MAX_PAGE_SIZE); throw e; }","preventionTips":["Cap page size at the server's MAX_PAGE_SIZE constant","Implement offset-based pagination loops instead of large single requests","Read the error message: it includes the exact allowed maximum"],"tags":["pagination","rest","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}