Skip to content

Commit

Permalink
fix(bff): zodError causing 500 error due to inconsistent zod versions (
Browse files Browse the repository at this point in the history
  • Loading branch information
keepview authored Oct 16, 2024
1 parent 91cf577 commit a4160c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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
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

0 comments on commit a4160c7

Please sign in to comment.