fix(errors): Show a better error when the sent JSON body as a syntax error (#1683)

Fixes HDX-3319
This commit is contained in:
Himanshu Kapoor 2026-01-30 17:55:52 +01:00 committed by GitHub
parent 2f1a13cc81
commit 4e7d04c7b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/api": patch
---
API: Show error "Invalid JSON payload" if the JSON body has a syntax error

View file

@ -15,7 +15,9 @@ export const appErrorHandler = (
const userFacingErrorMessage = isOperationalError(err) const userFacingErrorMessage = isOperationalError(err)
? err.name || err.message ? err.name || err.message
: 'Something went wrong :('; : err instanceof SyntaxError && err.message.includes('JSON')
? 'Invalid JSON payload'
: 'Something went wrong :(';
void recordException(err, { void recordException(err, {
mechanism: { mechanism: {