{"record":{"id":"4af866b535a7d4d0","repo":"theonedev/onedev","slug":"count-should-not-be-greater-than-max-commits","errorCode":null,"errorMessage":"Count should not be greater than ${MAX_COMMITS}","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/RepositoryResource.java","lineNumber":276,"sourceCode":"\n\t\treturn Response.ok().build();\n\t}\n\n\t@Api(order=83, description=\"Query commits of specified project. Will return list of matching commit hashes\")\n\t@Path(\"/{projectId}/commits\")\n\t@GET\n    public List<LogCommit> queryCommits(\n\t\t\t@PathParam(\"projectId\") Long projectId, \n    \t\t@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, \n    \t\t@QueryParam(\"count\") @Api(example=\"100\", description=\"Number of commits to return\") int count, \n\t\t\t@QueryParam(\"field\") @Api(exampleProvider = \"getFieldsExample\", description = \"Fields to return. Unspecified fields will return as null in returned commit object\") List<String> fields) {\n\t\tProject project = projectService.load(projectId);\n\t\tif (!SecurityUtils.canReadCode(project)) {\n\t\t\tthrow new UnauthorizedException();\n\t\t}\n\t\t\n    \tif (count > MAX_COMMITS)\n    \t\tthrow new NotAcceptableException(\"Count should not be greater than \" + MAX_COMMITS);\n\n\t\tvar parsedQuery = CommitQuery.parse(project, query, true);\n    \t\n\t\tRevListOptions options = new RevListOptions();\n\t\toptions.ignoreCase(true);\n\t\toptions.count(count);\n\t\tparsedQuery.fill(project, options);\n\n\t\tvar fieldSet = EnumSet.noneOf(LogCommand.Field.class);\n\t\tfieldSet.addAll(fields.stream().map(LogCommand.Field::valueOf).collect(toList()));\n\t\t\n\t\treturn gitService.log(project, options, fieldSet);\n    }\n\t\n\t@Api(order=86, description=\"Get specified commit\")\n\t@Path(\"/{projectId}/commits/{commitHash}\")\n\t@GET\n    public LogCommit getCommit(","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/rest/resource/RepositoryResource.java#L258-L294","documentation":"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.","triggerScenarios":"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.","commonSituations":"Migration/export scripts requesting huge counts; clients porting from other Git APIs without page-size limits; hardcoded large defaults in CI reporting tools.","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."],"exampleFix":"// before\nGET /api/projects/42/commits?count=10000\n\n// after\nGET /api/projects/42/commits?count=100&query=\"until commit(<last-seen-hash>)\"","handlingStrategy":"validation","validationCode":"const MAX_COMMITS = 1000; // match server limit stated in the error\nif (count > MAX_COMMITS) {\n  count = MAX_COMMITS; // or paginate\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["rest-api","pagination","validation"],"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-14T00:17:10.932Z"}