fix: use nonempty() for retry array type to match runtime validation#1199
fix: use nonempty() for retry array type to match runtime validation#1199claygeo wants to merge 2 commits into
Conversation
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
👷 Deploy request for quirrel-development-ui pending review.Visit the deploys page to approve it
|
👷 Deploy request for quirrel-docs pending review.Visit the deploys page to approve it
|
The schema change alone (.min(1) -> .nonempty()) only narrows the internal inferred type. The public hand-written EnqueueJobOptions interface still typed retry as (number|string)[], so it (a) did not reflect the runtime non-empty constraint users hit at runtime, and (b) was no longer assignable to the schema-inferred non-empty tuple, breaking tsc at enqueue()/enqueueMany(). Tighten retry to [number|string, ...(number|string)[]] so the public type rejects empty arrays at compile time, matching runtime validation. Closes quirrel-dev#1167. Verified: tsc --noEmit clean; client retry + schema-checks tests pass.
|
Reviving this one. The bug in #1167 still reproduces on current Verifying it surfaced something though, the original one-line schema change (
So I pushed a follow-up commit (bd9ff32) tightening the interface to One intended consequence: this tightens a public type, so code that builds (Forward-note: whenever zod moves to v4, Could a maintainer take another look when you get a chance? Happy to adjust. |
Problem
EnqueueJobOptions.retryis typed as(number | string)[]which allows empty arrays, but the Zod schema atsrc/client/index.ts:132enforces.min(1)at runtime. Passing an empty retry array fails with: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:[T, ...T[]](at least one element)The
.max(10)constraint is preserved.Changes
src/client/index.ts— Replaced.min(1)with.nonempty()on retry schemaCloses #1167