From 4452d0932a0e29b204c9d967ee0068183f50d064 Mon Sep 17 00:00:00 2001 From: Jo Date: Mon, 4 Nov 2024 18:50:26 +0100 Subject: [PATCH] Users: Fix potential panics on UID translation (#95794) fix potential panics on UID translation --- pkg/services/team/team.go | 4 ++++ pkg/services/user/user.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/services/team/team.go b/pkg/services/team/team.go index 74620af9f32..96704e5b4fd 100644 --- a/pkg/services/team/team.go +++ b/pkg/services/team/team.go @@ -32,6 +32,10 @@ func UIDToIDHandler(teamService Service) func(ctx context.Context, orgID int64, return resourceID, nil } team, err := teamService.GetTeamByID(ctx, &GetTeamByIDQuery{UID: resourceID, OrgID: orgID}) + if err != nil { + return "", err + } + return strconv.FormatInt(team.ID, 10), err } } diff --git a/pkg/services/user/user.go b/pkg/services/user/user.go index 7254d73a804..2b7712a52f1 100644 --- a/pkg/services/user/user.go +++ b/pkg/services/user/user.go @@ -40,6 +40,10 @@ func UIDToIDHandler(userService Service) func(ctx context.Context, userID string user, err := userService.GetByUID(ctx, &GetUserByUIDQuery{ UID: userID, }) + if err != nil { + return "", err + } + return strconv.FormatInt(user.ID, 10), err } }