SEZ9 opened a new pull request, #12070:
URL: https://github.com/apache/seatunnel/pull/12070
Close #12066
### Purpose of this pull request
`ExceptionHandlingFilter` puts the entire Java stack trace into the
`message` field of the JSON error body, so a caller who forgets `jobId` gets
forty frames of Zeta internals instead of "Job id is required".
The frames are already written to the server log on the next line of the
same method, so nothing is lost by leaving them there. This changes the body to
carry the exception type and message only, using `ExceptionUtils.getMessage(e)`
— the same call `BaseLogService` already uses in this module.
### Does this PR introduce _any_ user-facing change?
Yes, the `message` field of a v2 REST error response is shorter. HTTP status
codes and the `"status": "fail"` shape are unchanged.
Before:
```json
{
"status": "fail",
"message": "java.lang.IllegalArgumentException: Job id is required\n\tat
org.apache.seatunnel.engine.server.rest.service.JobInfoService.getJobInfo(JobInfoService.java:XX)\n\tat
javax.servlet.http.HttpServlet.service(HttpServlet.java:XX)\n\t... 40 more
frames ...\n"
}
```
After:
```json
{
"status": "fail",
"message": "IllegalArgumentException: Job id is required"
}
```
The stack trace is still logged at ERROR on the server, unchanged.
### How was this patch tested?
Added `ExceptionHandlingFilterTest`, which drives the filter with a chain
that throws and asserts on the JSON it writes:
- an `IllegalArgumentException` yields `400`, keeps both the exception type
and the message, keeps `"status":"fail"`, and contains no `at
org.apache.seatunnel` frames
- any other exception yields `500` with the same guarantees
`RestApiSubmitJobConfigShadeDecryptTest` already asserts on this response
for a bad-request case and passes unchanged, since `getMessage` still yields
`IllegalArgumentException: ...`.
### Check list
* [x] If any new Jar binary package adding in your PR, please add License
Notice according
[New License
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
* [x] If necessary, please update the documentation to describe the new
feature. https://github.com/apache/seatunnel/tree/dev/docs
* [x] If necessary, please update `incompatible-changes.md` to describe the
incompatibility caused by this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]