Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(api): Do not accept limit below 1 in pagination (#13855)

Ben Bachem06f8385b78b3
diff --git a/packages/shared/src/utils/zod.ts b/packages/shared/src/utils/zod.ts
index 0e8333e1ef..98125ccae0 100644
--- a/packages/shared/src/utils/zod.ts
+++ b/packages/shared/src/utils/zod.ts
@@ -44,6 +44,7 @@ export const paginationZod = {
(x) => (x === "" ? undefined : x),
z.coerce.number().nonnegative().default(1),
),
+ // For internal use, we allow a limit of 0 until LFE-9976 is merged
limit: z.preprocess(
(x) => (x === "" ? undefined : x),
z.coerce.number().nonnegative().lte(100).default(50),
@@ -57,7 +58,7 @@ export const publicApiPaginationZod = {
),
limit: z.preprocess(
(x) => (x === "" ? undefined : x),
- z.coerce.number().lte(100).default(50),
+ z.coerce.number().gte(1).lte(100).default(50),
),
};