Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bff): zodError causing 500 error due to inconsistent zod versions #6384

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/nervous-humans-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/bff-core': patch
---

fix(bff): zodError causing 500 error due to inconsistent zod versions
keepview marked this conversation as resolved.
Show resolved Hide resolved
fix(bff): 修复由于 zod 版本不一致导致的 zodError 触发的 500 错误
5 changes: 2 additions & 3 deletions packages/server/bff-core/src/operators/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ const validateInput = async <Schema extends z.ZodType>(
): Promise<z.output<Schema>> => {
try {
return await schema.parseAsync(input);
} catch (error) {
const { z: zod } = await import('zod');
if (error instanceof zod.ZodError) {
} catch (error: any) {
if ('name' in error && error.name === 'ZodError') {
throw new ValidationError(400, error.message);
}
throw error;
Expand Down
Loading