Skip to content

Keep trailers when a thrown status is unmapped - #445

Open
beyondwin wants to merge 1 commit into
spring-projects:mainfrom
beyondwin:fix-status-trailers
Open

beyondwin wants to merge 1 commit into
spring-projects:mainfrom
beyondwin:fix-status-trailers

Conversation

@beyondwin

Copy link
Copy Markdown

Throwing a StatusRuntimeException with trailers, such as google.rpc.Status details, drops those trailers when GrpcExceptionHandler returns null. onError with the same exception keeps them.

The fallback rebuilds the status with fromThrowable().asException(), which has no trailers. Handlers return null for exceptions they do not classify, and Spring Boot registers the interceptor even with no handler beans, so a thrown status usually takes this path.

Up to 0.8 the thrown trailers were sent (71355e6). The fixes for gh-193 and gh-332 switched to the handler result's trailers, and the fallback result has none. The fallback now copies trailersFromThrowable, as ServerCalls.onError does. A plain RuntimeException stays UNKNOWN with no description.

Fixes gh-444

Status.fromThrowable().asException() drops trailers, so a thrown
StatusRuntimeException loses google.rpc.Status details when the
handler returns null. onError already forwards them.

Copy those trailers onto the fallback status.

Fixes spring-projectsgh-444

Signed-off-by: WooSeung Kim <wooseung.dev@gmail.com>
@beyondwin
beyondwin force-pushed the fix-status-trailers branch from b92e8b6 to f06514f Compare November 6, 2026 00:19
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

Successfully merging this pull request may close these issues.

Thrown StatusRuntimeException loses its trailers when GrpcExceptionHandler returns null

1 participant