mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-12 09:05:12 +00:00
fix: recover from request panics (#11713)
# Which Problems Are Solved Panics may cause a service discruption by unexpectedly closing an request's connection. Or in the case of gRPC completely killing the service. Allthough panics are still individual bugs that need to be solved, this PR makes sure a panic is gracefully handled and an understandable error is returned to the client. # How the Problems Are Solved - Recover in the middleware interceptors for the 3 API protocols (HTTP, gRPC, connect). - HTTP middleware uses formatted responses for: - OIDC errors (JSON formatted response) - UI (error page rendering) - SCIM - Upon recovery an alert level log is printed (ERROR+4 for stdlib log handlers) # Additional Context - internal observation --------- Co-authored-by: Livio Spring <[email protected]> Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
Livio Spring
parent
bebee4c795
commit
5934e07960
@@ -70,7 +70,10 @@ func buildMiddleware(
|
||||
middlewares []zhttp_middlware.MiddlewareWithErrorFunc,
|
||||
) zhttp_middlware.ErrorHandlerFunc {
|
||||
// content type middleware needs to run at the very beginning to correctly set content types of errors
|
||||
middlewares = append([]zhttp_middlware.MiddlewareWithErrorFunc{smiddleware.ContentTypeMiddleware}, middlewares...)
|
||||
middlewares = append([]zhttp_middlware.MiddlewareWithErrorFunc{
|
||||
smiddleware.ContentTypeMiddleware,
|
||||
zhttp_middlware.RecoverHandlerWithError,
|
||||
}, middlewares...)
|
||||
middlewares = append(middlewares, smiddleware.ScimContextMiddleware(query))
|
||||
scimMiddleware := zhttp_middlware.ChainedWithErrorHandler(serrors.ErrorHandler(translator), middlewares...)
|
||||
return func(handler zhttp_middlware.HandlerFuncWithError) http.Handler {
|
||||
|
||||
Reference in New Issue
Block a user