yikart/AiToEarn · error · AppException

ChannelPaginationPageSizeExceeded

ChannelPaginationPageSizeExceeded

Error message

ChannelPaginationPageSizeExceeded

What it means

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.

Solutions

  1. Clamp pageSize to the platform's maxPageSize before the call: pageSize = Math.min(requestedPageSize, metadata.maxPageSize).
  2. Omit pageSize entirely so the platform's defaultPageSize is used.
  3. Read the platform's published pagination metadata (optionally via the metadata/capabilities endpoint) and offer only allowed page sizes in the UI.
  4. If the cap is wrong, update the platform integration's Page metadata maxPageSize.

Example fix

// before
await listWorks(accountId, { page: 1, pageSize: 200 })
// after
const meta = getPlatformPaginationMetadata(platform)
const pageSize = Math.min(200, meta.mode === ChannelPaginationMode.Page ? meta.maxPageSize : 200)
await listWorks(accountId, { page: 1, pageSize })
Defensive patterns

Strategy: validation

Validate before calling

const meta = platformPaginationMetadata[platform]
if (meta.mode === ChannelPaginationMode.Page && (requested.pageSize ?? 0) > meta.maxPageSize) {
  requested = { ...requested, pageSize: meta.maxPageSize }
}

Type guard

function isPageSizeAllowed(meta: ChannelPaginationMetadata, pageSize: number): boolean {
  return meta.mode === ChannelPaginationMode.Page && pageSize <= meta.maxPageSize
}

Try / catch

try {
  return await listItems({ page, pageSize })
} catch (e) {
  if (e instanceof AppException && e.code === ResponseCode.ChannelPaginationPageSizeExceeded) {
    return await listItems({ page, pageSize: e.details.maxPageSize })
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/042d39b310fa9305. Report an issue: GitHub.

Appendix: source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/platform-pagination.helper.ts:46

          platform,
          limit,
          maxLimit: cursorMetadata.maxLimit,
        })
      }
      const direction = normalized.direction ?? ChannelPaginationDirection.Next
      if (direction === ChannelPaginationDirection.Previous && !cursorMetadata.supportsPrevious) {
        throw new AppException(ResponseCode.ChannelPaginationDirectionNotSupported, {
          platform,
          direction,
        })
      }
      return { ...normalized, limit, direction }
    }
    case ChannelPaginationMode.Page: {
      const pageMetadata = metadata as Extract<ChannelPaginationMetadata, { mode: ChannelPaginationMode.Page }>
      const pageSize = normalized.pageSize ?? pageMetadata.defaultPageSize
      if (pageSize > pageMetadata.maxPageSize) {
        throw new AppException(ResponseCode.ChannelPaginationPageSizeExceeded, {
          platform,
          pageSize,
          maxPageSize: pageMetadata.maxPageSize,
        })
      }
      return { page: normalized.page ?? 1, pageSize }
    }
  }

  return normalized
}

function getDefaultPagination(
  metadata: ChannelPaginationMetadata,
  pagination: ChannelPaginationInput,
): ChannelPaginationInput {
  if (getPaginationInputMode(pagination) !== ChannelPaginationMode.None || metadata.mode === ChannelPaginationMode.None) {
    return pagination

View on GitHub (pinned to d3aa8bea5b)