{"record":{"id":"042d39b310fa9305","repo":"yikart/AiToEarn","slug":"channelpaginationpagesizeexceeded","errorCode":"ChannelPaginationPageSizeExceeded","errorMessage":"ChannelPaginationPageSizeExceeded","messagePattern":"ChannelPaginationPageSizeExceeded","errorType":"error_code","errorClass":"AppException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/platform-pagination.helper.ts","lineNumber":46,"sourceCode":"          platform,\n          limit,\n          maxLimit: cursorMetadata.maxLimit,\n        })\n      }\n      const direction = normalized.direction ?? ChannelPaginationDirection.Next\n      if (direction === ChannelPaginationDirection.Previous && !cursorMetadata.supportsPrevious) {\n        throw new AppException(ResponseCode.ChannelPaginationDirectionNotSupported, {\n          platform,\n          direction,\n        })\n      }\n      return { ...normalized, limit, direction }\n    }\n    case ChannelPaginationMode.Page: {\n      const pageMetadata = metadata as Extract<ChannelPaginationMetadata, { mode: ChannelPaginationMode.Page }>\n      const pageSize = normalized.pageSize ?? pageMetadata.defaultPageSize\n      if (pageSize > pageMetadata.maxPageSize) {\n        throw new AppException(ResponseCode.ChannelPaginationPageSizeExceeded, {\n          platform,\n          pageSize,\n          maxPageSize: pageMetadata.maxPageSize,\n        })\n      }\n      return { page: normalized.page ?? 1, pageSize }\n    }\n  }\n\n  return normalized\n}\n\nfunction getDefaultPagination(\n  metadata: ChannelPaginationMetadata,\n  pagination: ChannelPaginationInput,\n): ChannelPaginationInput {\n  if (getPaginationInputMode(pagination) !== ChannelPaginationMode.None || metadata.mode === ChannelPaginationMode.None) {\n    return pagination","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/platform-pagination.helper.ts#L28-L64","documentation":"In Page pagination mode, normalizeChannelPagination resolves pageSize to the platform's defaultPageSize when omitted, then enforces pageMetadata.maxPageSize. If the requested (or client-supplied) pageSize exceeds the platform's configured maximum, it throws ChannelPaginationPageSizeExceeded with the platform, requested pageSize, and allowed maxPageSize in the exception details.","triggerScenarios":"Calling a paginated listing endpoint with pageSize > the platform's maxPageSize (e.g. passing pageSize: 100 to a platform whose ChannelPaginationMetadata is { mode: Page, maxPageSize: 50 }). Triggered whenever page or pageSize fields are present in the request and the mode is Page.","commonSituations":"Hardcoding a large page size for 'fewer requests' across all platforms; a UI page-size selector offering 100/200 that exceeds some platform caps; a default page size changed upstream without checking each platform's metadata; API clients copied from a platform with a higher cap.","solutions":["Clamp pageSize to the platform's maxPageSize before the call: pageSize = Math.min(requestedPageSize, metadata.maxPageSize).","Omit pageSize entirely so the platform's defaultPageSize is used.","Read the platform's published pagination metadata (optionally via the metadata/capabilities endpoint) and offer only allowed page sizes in the UI.","If the cap is wrong, update the platform integration's Page metadata maxPageSize."],"exampleFix":"// before\nawait listWorks(accountId, { page: 1, pageSize: 200 })\n// after\nconst meta = getPlatformPaginationMetadata(platform)\nconst pageSize = Math.min(200, meta.mode === ChannelPaginationMode.Page ? meta.maxPageSize : 200)\nawait listWorks(accountId, { page: 1, pageSize })","handlingStrategy":"validation","validationCode":"const meta = platformPaginationMetadata[platform]\nif (meta.mode === ChannelPaginationMode.Page && (requested.pageSize ?? 0) > meta.maxPageSize) {\n  requested = { ...requested, pageSize: meta.maxPageSize }\n}","typeGuard":"function isPageSizeAllowed(meta: ChannelPaginationMetadata, pageSize: number): boolean {\n  return meta.mode === ChannelPaginationMode.Page && pageSize <= meta.maxPageSize\n}","tryCatchPattern":"try {\n  return await listItems({ page, pageSize })\n} catch (e) {\n  if (e instanceof AppException && e.code === ResponseCode.ChannelPaginationPageSizeExceeded) {\n    return await listItems({ page, pageSize: e.details.maxPageSize })\n  }\n  throw e\n}","preventionTips":["Clamp pageSize to the platform max before every paginated call.","Populate UI page-size dropdowns from the platform metadata, not hardcoded values.","Prefer omitting pageSize to accept the platform default.","Review page-size caps when adding or updating a platform integration."],"tags":["pagination","page-size","limits","validation"],"backgroundTag":"page-size-exceeded","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}