Skip to content

Fix error response bug#224

Merged
david-crespo merged 1 commit into
mainfrom
fix-validate-body
Dec 2, 2023
Merged

Fix error response bug#224
david-crespo merged 1 commit into
mainfrom
fix-validate-body

Conversation

@david-crespo

Copy link
Copy Markdown
Collaborator

Tiny bug introduced in #215, only affected error response on mock server, which we didn't notice because we pretty much only ever see zod error responses when inspecting a mock error response manually in the browser network tab.

const { body, bodyErr } = bodySchema
? validateBody(bodySchema, await req.json())
: { body: undefined, bodyErr: undefined };
if (bodyErr) return json(bodyErr, { status: 400 });

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bodyErr is already a Response, so we were seeing {} as the response body in the browser because JSON.stringify(new Response()) == '{}'.

@david-crespo david-crespo merged commit e9fd215 into main Dec 2, 2023
@david-crespo david-crespo deleted the fix-validate-body branch December 2, 2023 02:39
@david-crespo david-crespo mentioned this pull request Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant