diff --git a/internal/server/v1beta1/server.go b/internal/server/v1beta1/server.go index d91e2c51..6f605f36 100644 --- a/internal/server/v1beta1/server.go +++ b/internal/server/v1beta1/server.go @@ -2,6 +2,7 @@ package handlersv1beta1 import ( "context" + "encoding/json" "errors" "fmt" "net/http" @@ -11,6 +12,7 @@ import ( "github.com/odpf/compass/core/user" "github.com/odpf/salt/log" "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -55,6 +57,17 @@ func (server *APIServer) validateUserInCtx(ctx context.Context) (string, error) userID, err := server.userService.ValidateUser(ctx, usr.UUID, usr.Email) if err != nil { if errors.Is(err, user.ErrNoUserInformation) { + if md, ok := metadata.FromIncomingContext(ctx); ok { + jBytes, err := json.Marshal(md) + if err != nil { + server.logger.Debug("unable to marshal headers", "err", err) + } else { + server.logger.Debug("printing headers", "headers", string(jBytes)) + } + } else { + server.logger.Debug("could not get metadata") + } + return "", status.Errorf(codes.InvalidArgument, err.Error()) } if errors.As(err, &user.DuplicateRecordError{UUID: usr.UUID, Email: usr.Email}) {