Skip to content

Commit b805fa9

Browse files
committed
feat(blog): arity is the only check an exposed method gets
`@imqueue/validation` had zero coverage outside the package catalog and one FAQ answer, and "zod" appeared in exactly one post. The nearest published piece, /blog/type-safe-service-communication-typescript/, is entirely compile-time — it says "fully typed" and "fails to compile" and never reaches what happens once the argument is JSON on somebody else's queue. This is that half. Written against a real service on Redis 8.0.5 with a bare @imqueue/core caller rather than against the README, which was worth it. Before an exposed method runs, the only runtime check is IMQ_RPC_INVALID_ARGS_COUNT: a string, a number and null all land in a parameter typed as a class, and undeclared properties arrive intact. @classtype()/@Property() are not a runtime schema — they exist for the generated client, on the calling side. Four measured behaviours of @imqueue/validation carry the rest of the post: * the @validatable() buffer leak, which breaks a DIFFERENT class — a forgotten seal leaves `city` in the buffer and the next sealed class rejects valid credentials over a property it does not declare * transforming schemas validate and change nothing: z.coerce.number() accepts '3' and the body still gets the string, .default() fills nothing in and only makes the field optional * undeclared properties survive @validated(), because the parsed result is discarded; catchall(z.never()) is the explicit fix * a failure reaches a remote caller as IMQ_RPC_CALL_ERROR with the issue list as a message string, never as a ZodError — and the fix is not the decorator, whose throw happens outside the body, but parsing in the body and rethrowing with a code Cost: 32 ns plain against 119 ns guarded, so 87 ns, against a 40 µs median local round trip. The guarded and unguarded methods measure 39 µs and 40 µs over RPC. Carries an ## FAQ section, so the post emits FAQPage markup for four questions. npm test green on a clean build. Search KPI unmoved: P@1 macro 52.3% (identical to the pre-post baseline), micro 61.1%, recall@6 90.1%.
1 parent 0c271c8 commit b805fa9

3 files changed

Lines changed: 537 additions & 0 deletions

File tree

89.5 KB
Loading
Lines changed: 31 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)