Skip to content

Commit 4a249c1

Browse files
committed
fix: address coderabbit feedback on zod v4 migration
- core: forward the validated/normalized payload (parsedPayload.data) from the zod message sender instead of casting the raw input, so zod transforms, defaults, and coercions are applied on send - webapp: reword the feedback type union error to cover all feedback types, not just bug/feature
1 parent 2b0f9e9 commit 4a249c1

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

apps/webapp/app/routes/resources.feedback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const feedbackTypeLiterals = Object.keys(feedbackTypes).map((key) => z.literal(k
6161
const feedbackType = z.union(
6262
[feedbackTypeLiterals[0], feedbackTypeLiterals[1], ...feedbackTypeLiterals.slice(2)],
6363
{
64-
error: "Must be either 'bug' or 'feature'",
64+
error: "Must be a valid feedback type",
6565
}
6666
);
6767

packages/core/src/v3/zodMessageHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ export class ZodMessageSender<TMessageCatalog extends ZodMessageCatalogSchema> {
278278
}
279279

280280
try {
281-
// send side: payload is input; zod v4 distinguishes input/output on the sender signature
282-
await this.#sender({ type, payload: payload as any, version: "v1" });
281+
// send the validated/normalized output so zod transforms, defaults, and coercions are applied
282+
await this.#sender({ type, payload: parsedPayload.data, version: "v1" });
283283
} catch (error) {
284284
console.error("[ZodMessageSender] Failed to send message", error);
285285
}
@@ -334,8 +334,8 @@ export async function sendMessageInCatalog<TMessageCatalog extends ZodMessageCat
334334
throw new ZodSchemaParsedError(parsedPayload.error, payload);
335335
}
336336

337-
// send side: payload is input; zod v4 distinguishes input/output on the sender signature
338-
await sender({ type, payload: payload as any, version: "v1" });
337+
// send the validated/normalized output so zod transforms, defaults, and coercions are applied
338+
await sender({ type, payload: parsedPayload.data, version: "v1" });
339339
}
340340

341341
export type MessageCatalogToSocketIoEvents<TCatalog extends ZodMessageCatalogSchema> = {

0 commit comments

Comments
 (0)