nevzheng opened a new pull request, #13057:
URL: https://github.com/apache/gravitino/pull/13057
### What changes were proposed in this pull request?
This PR is the first scoped part of #12728. It prevents Gravitino's public
JSON error responses from exposing Java stack traces while retaining diagnostic
information inside the server.
- Redact `ErrorResponse.stack` at the shared server serialization boundary.
- Keep internal stack data and legacy stack-bearing payloads readable.
- Log the original throwable on the reported authorization-denial path.
- Make the Python client use the error message when `stack` is absent or
empty.
The explicit debug setting, request/correlation IDs, broader
exception-logging audit, OpenAPI example cleanup, and end-to-end endpoint sweep
remain follow-up work under #12728.
### Why are the changes needed?
Gravitino currently exposes internal class names, source lines, and
framework proxy details to authenticated and unauthenticated callers. Clients
already have the stable `code`, `type`, and `message` fields they need.
Removing `stack` also exposed a Python-client compatibility problem: an
omitted stack produced a blank formatted error. This patch keeps errors
readable across new and legacy server responses.
Related to: #12728
### Does this PR introduce _any_ user-facing change?
Yes. Public Gravitino JSON error responses no longer include the optional
`stack` property. The `code`, `type`, and `message` fields are unchanged.
New clients remain compatible with older servers that return `stack`; no
user configuration or migration is required.
### How was this patch tested?
- Focused Java tests for internal stack retention, shared-mapper redaction,
raw authentication responses, legacy deserialization, and authorization
throwable logging.
- Complete `TestGravitinoInterceptionService`.
- Sixteen focused Python DTO and error-handler tests, including missing,
empty, and legacy populated stacks.
- Spotless and Black formatting checks.
- Focused Pylint: `10.00/10`.
- Clean cherry-pick onto current `branch-1.3`, followed by the same focused
Java and Python tests.
A broader authenticated and unauthenticated end-to-end route sweep is
intentionally deferred and will be followed up under #12728.
<details>
<summary>Appendix: error boundary and follow-up scope</summary>
```mermaid
flowchart LR
A[Java Throwable] --> B[Internal ErrorResponse<br/>stack retained]
A -->|reported authorization path| C[(Server log<br/>original Throwable)]
B --> D[Shared server ObjectMapper]
D -->|outbound serialization| E[Public JSON<br/>code + type + message]
E --> F[Java / Python clients]
G[Legacy response<br/>with stack] -->|still accepted| F
```
| Included in this PR | Follow-up under
#12728 |
| :--------------------------------------------------- |
:----------------------------------------------------------- |
| Public stack redaction | Explicit server
debug setting |
| Original throwable logging on the authorization path | Broader
exception-mapping and logging audit |
| Focused Java, raw-JSON, and Python regressions | Request/correlation
IDs and representative end-to-end routes |
| Legacy response compatibility | OpenAPI example
cleanup |
</details>
--
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]