{"record":{"id":"e9d076f8926e4941","repo":"Budibase/budibase","slug":"cannot-paginate-query-without-a-limit","errorCode":null,"errorMessage":"Cannot paginate query without a limit","messagePattern":"Cannot paginate query without a limit","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/sdk/workspace/rows/search/external.ts","lineNumber":42,"sourceCode":"import { outputProcessing } from \"../../../../utilities/rowProcessor\"\nimport { ExportRowsParams, ExportRowsResult } from \"./types\"\nimport { isSearchingByRowID } from \"./utils\"\n\nfunction getPaginationAndLimitParameters(\n  filters: SearchFilters,\n  paginate: boolean | undefined,\n  bookmark: number | undefined,\n  limit: number | undefined\n): PaginationJson | undefined {\n  let paginateObj: PaginationJson | undefined\n\n  // only try set limits/pagination if we aren't doing a row ID search\n  if (isSearchingByRowID(filters)) {\n    return\n  }\n\n  if (paginate && !limit) {\n    throw new Error(\"Cannot paginate query without a limit\")\n  }\n\n  if (paginate && limit) {\n    paginateObj = {\n      // add one so we can track if there is another page\n      limit: limit + 1,\n    }\n    if (bookmark) {\n      paginateObj.offset = bookmark\n    }\n  } else if (limit) {\n    paginateObj = {\n      limit: limit,\n    }\n  }\n\n  return paginateObj\n}","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/rows/search/external.ts#L24-L60","documentation":"When pagination is requested (`paginate: true`) for an external table search, a `limit` must also be provided, because the pagination math needs a page size. Searching by row ID short-circuits before this check.","triggerScenarios":"Calling external search with paginate=true but no limit, e.g. through sdk.rows.search on an external table with pagination enabled.","commonSituations":"Client enables 'next page' UI without setting a page size; default limit lost between layers; passing paginate flag from one config and limit from another where limit is undefined.","solutions":["Provide a limit whenever paginate is true","Or disable pagination (paginate: false) for unbounded searches","Default the limit in the calling layer (e.g. limit ?? 50)"],"exampleFix":"// before\nawait sdk.rows.search({ tableId, query, paginate: true })\n// after\nawait sdk.rows.search({ tableId, query, paginate: true, limit: 25 })","handlingStrategy":"validation","validationCode":"if (opts.paginate && !opts.limit) opts.limit = 25","typeGuard":null,"tryCatchPattern":"try { await sdk.rows.search(opts) } catch (e) { if (e.message.includes('Cannot paginate query without a limit')) { /* set limit and retry */ } else throw e }","preventionTips":["Always pair paginate:true with a limit","Set a default page size in the calling layer","Centralize search option construction"],"tags":["pagination","external-tables","missing-argument"],"backgroundTag":"pagination-requires-limit","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}