Skip to content

fix: use nonempty() for retry array type to match runtime validation#1199

Open
claygeo wants to merge 1 commit intoquirrel-dev:mainfrom
claygeo:fix/enqueue-retry-type
Open

fix: use nonempty() for retry array type to match runtime validation#1199
claygeo wants to merge 1 commit intoquirrel-dev:mainfrom
claygeo:fix/enqueue-retry-type

Conversation

@claygeo
Copy link
Copy Markdown

@claygeo claygeo commented Mar 27, 2026

Problem

EnqueueJobOptions.retry is typed as (number | string)[] which allows empty arrays, but the Zod schema at src/client/index.ts:132 enforces .min(1) at runtime. Passing an empty retry array fails with:

body/retry must NOT have fewer than 1 items

The type doesn't reflect this constraint because Zod's .min() does not change the inferred type.

Solution

Replace .min(1) with .nonempty(), which both:

  • Enforces the minimum at runtime (same behavior)
  • Narrows the inferred TypeScript type to [T, ...T[]] (at least one element)

The .max(10) constraint is preserved.

- retry: z.array(timeDuration("retry")).min(1).max(10).optional(),
+ retry: z.array(timeDuration("retry")).nonempty().max(10).optional(),

Changes

  • src/client/index.ts — Replaced .min(1) with .nonempty() on retry schema

Closes #1167

The Zod schema enforces .min(1).max(10) on the retry array, but
.min() does not change the inferred TypeScript type. This means
the type allows empty arrays while the runtime rejects them with
"body/retry must NOT have fewer than 1 items".

Replace .min(1) with .nonempty() which both enforces the minimum
at runtime AND narrows the inferred type to require at least one
element, aligning the TypeScript type with the runtime behavior.

Closes quirrel-dev#1167
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

👷 Deploy request for quirrel-development-ui pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 55f418a

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

👷 Deploy request for quirrel-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 55f418a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EnqueueJobOptions retry type wrong

1 participant