Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Better Error Message for invalid JSON #869

Open
krowvin opened this issue Sep 6, 2024 · 0 comments
Open

Add Better Error Message for invalid JSON #869

krowvin opened this issue Sep 6, 2024 · 0 comments

Comments

@krowvin
Copy link
Collaborator

krowvin commented Sep 6, 2024

If a user tries to make a POST request with JSON, catch the error and return INVALID JSON. More descriptive error.

Currently you get the generic response, and have to check the logs:

{
  "message": "System Error",
  "incidentIdentifier": "-1457776659434189887",
  "details": {}
}

to which if you go to the error in the logs it is immaculate and I immediately knew the issue.

com.fasterxml.jackson.core.JsonParseException: Unexpected character ('}' (code 125)): was expecting double-quote to start field name

Suggest user test JSON payload in VSCode to verify integrity

I.e.

curl -X 'POST' \
  't7hostnamel:tomcatport/swt-data/auth/keys' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "user-id": "myuserid",
  "key-name": "test"
}'
{
  "user-id": "myuserid",
  "key-name": "test"
},
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

No branches or pull requests

1 participant