Add Better Error Message for invalid JSON
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 28
- Forks
- 25
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 20
Description
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"
},
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the POST endpoint shown in the issue, /swt-data/auth/keys, and trace how the Jackson JsonParseException becomes the generic System Error response. Reproduce the malformed JSON request, then verify that invalid JSON returns a descriptive INVALID JSON response instead of only the incident identifier and empty details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100