fix(regressions): client-bundle ioredis + Drizzle ANY() array bindings
Two regressions from yesterday's audit-tier-0 work that broke the dev
server and every clients API call.
- baseListQuerySchema lived in route-helpers.ts, which was made
server-only by the rate-limit import. Every validator imported it,
pulling ioredis (and dns/net/tls/fs/node:async_hooks) into the client
bundle — every form/detail page returned 500 in dev. Extracted the
schema to src/lib/api/list-query.ts and updated all 14 validators.
- clients.service.listClients and email-compose used raw SQL
ANY(\${jsArray}) which Drizzle binds as JSON — Postgres rejects with
42809 "op ANY/ALL (array) requires array on right side". Switched to
the inArray helper.
GET /api/v1/clients now returns 200 again. Affects every form/detail
page that imports a validator.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
15
src/lib/api/list-query.ts
Normal file
15
src/lib/api/list-query.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const baseListQuerySchema = z.object({
|
||||
page: z.coerce.number().int().min(1).default(1),
|
||||
limit: z.coerce.number().int().min(1).max(100).default(25),
|
||||
sort: z.string().optional(),
|
||||
order: z.enum(['asc', 'desc']).default('desc'),
|
||||
search: z.string().optional(),
|
||||
includeArchived: z
|
||||
.enum(['true', 'false'])
|
||||
.transform((v) => v === 'true')
|
||||
.default('false'),
|
||||
});
|
||||
|
||||
export type BaseListQuery = z.infer<typeof baseListQuerySchema>;
|
||||
@@ -8,23 +8,6 @@ import {
|
||||
type RateLimiterName,
|
||||
} from '@/lib/rate-limit';
|
||||
|
||||
/**
|
||||
* Base list query schema shared by all paginated list endpoints.
|
||||
*/
|
||||
export const baseListQuerySchema = z.object({
|
||||
page: z.coerce.number().int().min(1).default(1),
|
||||
limit: z.coerce.number().int().min(1).max(100).default(25),
|
||||
sort: z.string().optional(),
|
||||
order: z.enum(['asc', 'desc']).default('desc'),
|
||||
search: z.string().optional(),
|
||||
includeArchived: z
|
||||
.enum(['true', 'false'])
|
||||
.transform((v) => v === 'true')
|
||||
.default('false'),
|
||||
});
|
||||
|
||||
export type BaseListQuery = z.infer<typeof baseListQuerySchema>;
|
||||
|
||||
/**
|
||||
* Parses URL search params against a Zod schema.
|
||||
* Throws a ZodError on validation failure (caught by `errorResponse`).
|
||||
|
||||
Reference in New Issue
Block a user