From 58ebbc5cdc6f871c5ca6749f8bad3785b80068bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Rodr=C3=ADguez?= Date: Thu, 16 Jan 2025 13:34:39 +0100 Subject: [PATCH] fix(orgmetrics): Prevent org metrics if org does not exist (#1734) Signed-off-by: Javier Rodriguez --- app/controlplane/pkg/biz/orgmetrics.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controlplane/pkg/biz/orgmetrics.go b/app/controlplane/pkg/biz/orgmetrics.go index aa7f38d2f..5ee440f4d 100644 --- a/app/controlplane/pkg/biz/orgmetrics.go +++ b/app/controlplane/pkg/biz/orgmetrics.go @@ -170,6 +170,11 @@ func (uc *OrgMetricsUseCase) GetLastWorkflowStatusByRun(ctx context.Context, org return nil, fmt.Errorf("finding organization: %w", err) } + // Check if organization exists, return empty list if not + if org == nil { + return nil, NewErrNotFound("organization") + } + // Default pagination option paginationOpts, err := pagination.NewOffsetPaginationOpts(pagination.DefaultPage, 100) if err != nil {