From 392124de0059f92cbf41c6db84034a84134fa599 Mon Sep 17 00:00:00 2001 From: Ieva Date: Fri, 7 Mar 2025 13:37:26 +0000 Subject: [PATCH] Service Accounts: Don't show error pop-ups for Service Account and Renderer UI flows (#101776) * don't show error pop-ups for SAs and renderer * only hide non 4xx error pop'ups * linting --- pkg/api/user.go | 4 ++-- public/app/core/services/backend_srv.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/api/user.go b/pkg/api/user.go index 22e92e59e7a..8bc33207ac1 100644 --- a/pkg/api/user.go +++ b/pkg/api/user.go @@ -505,7 +505,7 @@ func (hs *HTTPServer) ChangeActiveOrgAndRedirectToHome(c *contextmodel.ReqContex if !c.SignedInUser.IsIdentityType(claims.TypeUser) { hs.log.Debug("Requested endpoint only available to users") - c.JsonApiErr(http.StatusForbidden, "Endpoint only available for users", nil) + c.JsonApiErr(http.StatusNotModified, "Endpoint only available for users", nil) return } @@ -631,7 +631,7 @@ func (hs *HTTPServer) ClearHelpFlags(c *contextmodel.ReqContext) response.Respon func (hs *HTTPServer) getUserID(c *contextmodel.ReqContext) (int64, *response.NormalResponse) { if !c.SignedInUser.IsIdentityType(claims.TypeUser) { hs.log.Debug("Requested endpoint only available to users") - return 0, response.Error(http.StatusForbidden, "Endpoint only available for users", nil) + return 0, response.Error(http.StatusNotModified, "Endpoint only available for users", nil) } userID, err := c.SignedInUser.GetInternalID() diff --git a/public/app/core/services/backend_srv.ts b/public/app/core/services/backend_srv.ts index 3f2c645a300..f0f42225547 100644 --- a/public/app/core/services/backend_srv.ts +++ b/public/app/core/services/backend_srv.ts @@ -347,8 +347,9 @@ export class BackendSrv implements BackendService { } showErrorAlert(config: BackendSrvRequest, err: FetchError) { - // do not show error alerts for api keys or render tokens, they are used for kiosk mode and reporting and can't react to error pop-ups + // do not show non-user error alerts for api keys or render tokens, they are used for kiosk mode and reporting and can't react to error pop-ups if ( + (err.status < 400 || err.status >= 500) && this.dependencies.contextSrv.isSignedIn && (this.dependencies.contextSrv.user.authenticatedBy === 'apikey' || this.dependencies.contextSrv.user.authenticatedBy === 'render')