From 862ec3b6726fc1867d576ab537257fea4dfed004 Mon Sep 17 00:00:00 2001 From: Alex Demidoff Date: Fri, 12 Jul 2024 14:55:42 +0300 Subject: [PATCH] PMM-13054 try better error msg to debug failures --- managed/services/grafana/auth_server.go | 4 ++-- managed/utils/interceptors/interceptors.go | 2 +- utils/errors/errors.go | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/managed/services/grafana/auth_server.go b/managed/services/grafana/auth_server.go index 4379d23ad0..0c183dbfd8 100644 --- a/managed/services/grafana/auth_server.go +++ b/managed/services/grafana/auth_server.go @@ -579,7 +579,7 @@ func (s *AuthServer) getAuthUser(ctx context.Context, req *http.Request, l *logr j, err := json.Marshal(authHeaders) if err != nil { l.Warnf("%s", err) - return nil, &authError{code: codes.Internal, message: "Internal server error."} + return nil, &authError{code: codes.Internal, message: "Error marshalling headers."} } hash := base64.StdEncoding.EncodeToString(j) s.rw.RLock() @@ -616,7 +616,7 @@ func (s *AuthServer) retrieveRole(ctx context.Context, hash string, authHeaders } return nil, &authError{code: code, message: cErr.ErrorMessage} } - return nil, &authError{code: codes.Internal, message: "Internal server error."} + return nil, &authError{code: codes.Internal, message: err.Error()} } s.rw.Lock() s.cache[hash] = cacheItem{ diff --git a/managed/utils/interceptors/interceptors.go b/managed/utils/interceptors/interceptors.go index e58c86441f..aae9f76447 100644 --- a/managed/utils/interceptors/interceptors.go +++ b/managed/utils/interceptors/interceptors.go @@ -70,7 +70,7 @@ func logRequest(l *logrus.Entry, prefix string, f func() error) (err error) { default: // %+v for inner stacktraces produced by errors.WithStack(err) l.Errorf("%s done in %s with unexpected error: %+v", prefix, dur, err) - err = status.Error(codes.Internal, "Internal server error.") + err = status.Error(codes.Internal, err.Error()) } }() diff --git a/utils/errors/errors.go b/utils/errors/errors.go index 76b9e91941..912698a057 100644 --- a/utils/errors/errors.go +++ b/utils/errors/errors.go @@ -157,5 +157,6 @@ func PMMRoutingErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshale Err: status.Error(codes.NotFound, msg), } - runtime.DefaultHTTPErrorHandler(ctx, mux, marshaler, w, r, err) + // runtime.DefaultHTTPErrorHandler(ctx, mux, marshaler, w, r, err) + PMMHTTPErrorHandler(ctx, mux, marshaler, w, r, err) }