Skip to content

Commit 499ce65

Browse files
authored
Handle potential JSON parsing errors in Axiom body logging (dubinc#3100)
1 parent 805d48e commit 499ce65

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

apps/web/lib/axiom/server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ export const withAxiomBodyLog = createAxiomRouteHandler(logger, {
4444

4545
// Add body to report if the method is POST, PATCH, or PUT
4646
if (["POST", "PATCH", "PUT"].includes(data.req.method)) {
47-
report.body = await data.req.json();
47+
try {
48+
report.body = await data.req.json();
49+
} catch (error) {
50+
// Body might be empty, invalid JSON
51+
// Silently skip adding body to report
52+
}
4853
}
4954

5055
// Add search params to report

0 commit comments

Comments
 (0)