{"record":{"id":"2f493b1756256691","repo":"theonedev/onedev","slug":"count-should-not-be-greater-than-restconstants-m","errorCode":null,"errorMessage":"Count should not be greater than ${RestConstants.MAX_PAGE_SIZE}","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":438,"sourceCode":"        return DateUtils.parseRelaxed(dateTimeDescription).getTime();\n    }\n \n    @Path(\"/query-issues\")\n    @GET\n    public List<Map<String, Object>> queryIssues(\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 (count > RestConstants.MAX_PAGE_SIZE)\n            throw new NotAcceptableException(\"Count should not be greater than \" + RestConstants.MAX_PAGE_SIZE);\n\n        EntityQuery<Issue> parsedQuery;\n        if (query != null) {\n            var option = new IssueQueryParseOption();\n            option.withCurrentUserCriteria(true);\n            parsedQuery = IssueQuery.parse(projectContext.project, query, option, true);\n        } else {\n            parsedQuery = new IssueQuery(null, new ArrayList<>());\n        }\n\n        var summaries = new ArrayList<Map<String, Object>>();\n        for (var issue : issueService.query(subject, new ProjectScope(projectContext.project, true, false), parsedQuery, true, offset, count)) {\n            var summary = IssueHelper.getSummary(projectContext.currentProject, issue);\n            for (var entry: issue.getFieldInputs().entrySet()) {\n                summary.put(entry.getKey(), entry.getValue().getValues());\n            }\n            summary.put(\"link\", urlService.urlFor(issue, true));\n            summaries.add(summary);","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/ai/TodResource.java#L420-L456","documentation":"queryIssues rejects a page size larger than RestConstants.MAX_PAGE_SIZE by throwing NotAcceptableException with this message. OneDev caps list endpoints to protect the server from huge result pages. The client must request count <= MAX_PAGE_SIZE and paginate with offset.","triggerScenarios":"Calling the AI query-issues endpoint with a count query parameter whose integer value exceeds RestConstants.MAX_PAGE_SIZE (default 100 in OneDev REST constants), e.g. count=500.","commonSituations":"A client script passing a large count to 'get everything at once'; an AI agent guessing a page size; a UI forwarding an unbounded user-supplied page size.","solutions":["Lower the count parameter to RestConstants.MAX_PAGE_SIZE or below (e.g. count=100).","Paginate: keep count at the max and step offset by count until fewer than count results return.","Check RestConstants.MAX_PAGE_SIZE in the server version you run to know the exact cap."],"exampleFix":"// before\nGET /api/tod/query-issues?query=state=Open&offset=0&count=500\n// after\nGET /api/tod/query-issues?query=state=Open&offset=0&count=100  // then offset=100, offset=200 ...","handlingStrategy":"validation","validationCode":"const MAX_PAGE_SIZE = 100;\nfunction validateCount(count) {\n  const n = Number(count);\n  if (!Number.isInteger(n) || n <= 0 || n > MAX_PAGE_SIZE)\n    throw new RangeError(`count must be 1..${MAX_PAGE_SIZE}`);\n  return n;\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await queryIssues({ ...params, count: Math.min(params.count, 100) });\n} catch (e) {\n  if (/Count should not be greater than/.test(e.message)) {\n    return paginate(params, 100);\n  }\n  throw e;\n}","preventionTips":["Clamp count to the server max in your API wrapper.","Implement offset-based pagination helpers instead of large single fetches.","Pin the MAX_PAGE_SIZE constant per server version."],"tags":["rest","pagination","validation"],"backgroundTag":"argument-out-of-range","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"}