Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Handle potential JSON parsing errors in Axiom body logging (#3100)

Kiran K499ce6599976
diff --git a/apps/web/lib/axiom/server.ts b/apps/web/lib/axiom/server.ts
index 69a916a671..520a3fd979 100644
--- a/apps/web/lib/axiom/server.ts
+++ b/apps/web/lib/axiom/server.ts
@@ -44,7 +44,12 @@ export const withAxiomBodyLog = createAxiomRouteHandler(logger, {
// Add body to report if the method is POST, PATCH, or PUT
if (["POST", "PATCH", "PUT"].includes(data.req.method)) {
- report.body = await data.req.json();
+ try {
+ report.body = await data.req.json();
+ } catch (error) {
+ // Body might be empty, invalid JSON
+ // Silently skip adding body to report
+ }
}
// Add search params to report