dub
dub copied to clipboard
Quick Fix: Inconsistent Error Responses for Invalid JSON in API Requests
When sending invalid JSON to PATCH /links/{linkId} and POST /links/bulk, we're getting an "internal server error" instead of the more helpful "bad request" error.
However, POST /links gets it right and tells us it's a "bad request" due to invalid JSON.
I believe this will help everyone using the API to have a smoother and more predictable experience.
I've already fixed it by first checking:
const bodyRaw = await parseRequestBody(req);
const links = bulkCreateLinksBodySchema.parse(bodyRaw);
I hope this helps make Dub better!
@aliamerj is attempting to deploy a commit to the Dub Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| dub | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 6, 2024 8:47am |
Brilliant work, thank you @aliamerj!
Thanks