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 committed Oct 15, 2024
1 parent a33d0da commit fa79523
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-humans-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modern-js/bff-core': patch
---

fix(bff): zodError causing 500 error due to inconsistent zod versions
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"**/node_modules": false
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.defaultFormatter": "vscode.typescript-language-features",
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports": "never",
Expand Down
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
50 changes: 36 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fa79523

Please sign in to comment.