FuelLabs/fuels-ts · warning · FuelError
INVALID_INPUT_PARAMETERS
INVALID_INPUT_PARAMETERS
Error message
Pagination arguments "after" and "before" cannot be used together
What it means
Thrown by `validatePaginationArgs()` when both `after` and `before` cursor arguments are supplied simultaneously. GraphQL cursor pagination semantics are exclusive: you page forward from `after` or backward from `before`, never both at once. The validator rejects this before the query is sent to the node.
Source
Thrown at packages/account/src/providers/utils/validate-pagination-args.ts:16
import { FuelError, ErrorCode } from '@fuel-ts/errors';
import type { CursorPaginationArgs } from '../provider';
/**
* @hidden
*/
export const validatePaginationArgs = (params: {
inputArgs?: CursorPaginationArgs;
paginationLimit: number;
}): CursorPaginationArgs => {
const { paginationLimit, inputArgs = {} } = params;
const { first, last, after, before } = inputArgs;
if (after && before) {
throw new FuelError(
ErrorCode.INVALID_INPUT_PARAMETERS,
'Pagination arguments "after" and "before" cannot be used together'
);
}
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
throw new FuelError(
ErrorCode.INVALID_INPUT_PARAMETERS,
`Pagination limit for this query cannot exceed ${paginationLimit} items`
);
}
if (first && before) {
throw new FuelError(
ErrorCode.INVALID_INPUT_PARAMETERS,
'The use of pagination argument "first" with "before" is not supported'
);
}View on GitHub (pinned to b3f37c91ac)
Solutions
- Pass only one of `after` (forward) or `before` (backward) per query.
- Reset the opposing cursor to undefined when setting one.
- Use the helper `validatePaginationArgs` directly to test your args before calling the provider.
Example fix
// before
provider.getTransactions({ first: 10, after: cursorA, before: cursorB });
// after
provider.getTransactions({ first: 10, after: cursorA });
// for backward paging:
provider.getTransactions({ last: 10, before: cursorB }); Defensive patterns
Strategy: validation
Validate before calling
function validateCursors(args: { after?: string; before?: string }) {
if (args.after && args.before) throw new Error('use after XOR before, not both');
return args.after ? { after: args.after } : args.before ? { before: args.before } : {};
} Type guard
null
Try / catch
null
Prevention
- Pass only after (forward) or before (backward), not both.
- Reset the opposing cursor when setting one in UI state.
- Centralize cursor handling in one pagination module.
When it happens
Trigger: Calling any paginated provider query (e.g. `getTransactions`, `getBlocks`, `getCoins`) with `inputArgs: { after, before }` both set to cursor strings. The validator at validate-pagination-args.ts:15 trips.
Common situations: Generic pagination UI that always forwards both cursors from a previous response; merging page-state objects naively; building a 'jump to page' feature that sets both bounds.
Related errors
AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12).
Data as JSON: /api/errors/c96ccd047f8c305c.
Report an issue: GitHub.