From 6e5469bce0980116189064731ebbadb2acee003b Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Mon, 2 Feb 2026 19:41:53 +0100 Subject: [PATCH 1/3] fix: handle 404 correctly Signed-off-by: Miguel Martinez --- app/controlplane/pkg/data/casmapping.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controlplane/pkg/data/casmapping.go b/app/controlplane/pkg/data/casmapping.go index 7bf136d33..e7f87e7d0 100644 --- a/app/controlplane/pkg/data/casmapping.go +++ b/app/controlplane/pkg/data/casmapping.go @@ -82,7 +82,7 @@ func (r *CASMappingRepo) FindByDigest(ctx context.Context, digest string) ([]*bi for _, m := range mappings { public, err := r.IsPublic(ctx, r.data.DB, m.WorkflowRunID) if err != nil { - if biz.IsNotFound(err) { + if ent.IsNotFound(err) { return nil, nil } @@ -112,7 +112,7 @@ func (r *CASMappingRepo) findByID(ctx context.Context, id uuid.UUID) (*biz.CASMa public, err := r.IsPublic(ctx, r.data.DB, backend.WorkflowRunID) if err != nil { - if biz.IsNotFound(err) { + if ent.IsNotFound(err) { return nil, nil } @@ -132,15 +132,11 @@ func (r *CASMappingRepo) IsPublic(ctx context.Context, client *ent.Client, runID wr, err := client.WorkflowRun.Query().Where(workflowrun.ID(runID)).Select(workflowrun.FieldWorkflowID).First(ctx) if err != nil { return false, fmt.Errorf("failed to get workflow run: %w", err) - } else if wr == nil { - return false, nil } workflow, err := client.Workflow.Query().Where(workflow.ID(wr.WorkflowID)).Select(workflow.FieldPublic).First(ctx) if err != nil { return false, fmt.Errorf("failed to get workflow: %w", err) - } else if workflow == nil { - return false, nil } return workflow.Public, nil From 72f26006c4ac1d50463f58aa07b071e5a04eac24 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Mon, 2 Feb 2026 19:45:07 +0100 Subject: [PATCH 2/3] fix: handle 404 correctly Signed-off-by: Miguel Martinez --- app/controlplane/pkg/data/casmapping.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controlplane/pkg/data/casmapping.go b/app/controlplane/pkg/data/casmapping.go index e7f87e7d0..5265ef9f5 100644 --- a/app/controlplane/pkg/data/casmapping.go +++ b/app/controlplane/pkg/data/casmapping.go @@ -83,7 +83,7 @@ func (r *CASMappingRepo) FindByDigest(ctx context.Context, digest string) ([]*bi public, err := r.IsPublic(ctx, r.data.DB, m.WorkflowRunID) if err != nil { if ent.IsNotFound(err) { - return nil, nil + continue } return nil, fmt.Errorf("failed to check if workflow is public: %w", err) From 2a4bb977d96ba286500aa493655391b96b842810 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Mon, 2 Feb 2026 22:13:29 +0100 Subject: [PATCH 3/3] fix: handle 404 correctly Signed-off-by: Miguel Martinez --- app/controlplane/pkg/biz/casmapping.go | 2 +- app/controlplane/pkg/data/casmapping.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controlplane/pkg/biz/casmapping.go b/app/controlplane/pkg/biz/casmapping.go index 9eb88a87e..a51d118b1 100644 --- a/app/controlplane/pkg/biz/casmapping.go +++ b/app/controlplane/pkg/biz/casmapping.go @@ -1,5 +1,5 @@ // -// Copyright 2023-2025 The Chainloop Authors. +// Copyright 2023-2026 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/app/controlplane/pkg/data/casmapping.go b/app/controlplane/pkg/data/casmapping.go index 5265ef9f5..cb0d0f445 100644 --- a/app/controlplane/pkg/data/casmapping.go +++ b/app/controlplane/pkg/data/casmapping.go @@ -1,5 +1,5 @@ // -// Copyright 2024-2025 The Chainloop Authors. +// Copyright 2024-2026 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -113,7 +113,7 @@ func (r *CASMappingRepo) findByID(ctx context.Context, id uuid.UUID) (*biz.CASMa public, err := r.IsPublic(ctx, r.data.DB, backend.WorkflowRunID) if err != nil { if ent.IsNotFound(err) { - return nil, nil + return nil, biz.NewErrNotFound("cas mapping") } return nil, fmt.Errorf("failed to check if workflow is public: %w", err)