Skip to content

Commit

Permalink
PMM-13054 try better error msg to debug failures
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Jul 12, 2024
1 parent 8a27e2a commit 862ec3b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions managed/services/grafana/auth_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion managed/utils/interceptors/interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}()

Expand Down
3 changes: 2 additions & 1 deletion utils/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 862ec3b

Please sign in to comment.