From f932b89a9c58d8d87be246d10ecf77680ab9503a Mon Sep 17 00:00:00 2001 From: leon-schmid Date: Wed, 20 Nov 2024 16:09:45 +0100 Subject: [PATCH] fix: correctly parse a limit of 0 and handle negative limit --- web/src/hooks/use-list-workflow-runs-api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/hooks/use-list-workflow-runs-api.ts b/web/src/hooks/use-list-workflow-runs-api.ts index 210cc1d..086b337 100644 --- a/web/src/hooks/use-list-workflow-runs-api.ts +++ b/web/src/hooks/use-list-workflow-runs-api.ts @@ -8,7 +8,7 @@ import { HTTPMethod } from "@/types/api"; // GET /api/v1/runs/ const ListWorkflowRunsRequest = z.object({ - limit: z.number().optional(), + limit: z.number().min(0).optional(), }); const ListWorkflowRunsResponse = z.array(WorkflowRunMetadata); @@ -29,7 +29,7 @@ export const useListWorkflowRunsApi = (workflowId: string, limit?: number) => { return useQuery({ queryKey: ["workflowRuns", workflowId, limit], queryFn: () => { - const params = limit ? { limit } : {}; + const params = typeof limit === "number" ? { limit } : {}; return buildListWorkflowRunsApi(workflowId)(params); }, refetchInterval: REFETCH_INTERVAL_1_SECOND,