From dfc4becdfc54bb20ff7bf9917bda8ce8c44ab3a9 Mon Sep 17 00:00:00 2001 From: Dylan Ratcliffe Date: Mon, 9 Dec 2024 16:19:40 +0000 Subject: [PATCH 1/2] Send errors with list --- adapterhelpers/always_get_source.go | 7 +++++-- adapters/kms-key_test.go | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/adapterhelpers/always_get_source.go b/adapterhelpers/always_get_source.go index 5cb8111d..f881bab5 100644 --- a/adapterhelpers/always_get_source.go +++ b/adapterhelpers/always_get_source.go @@ -264,9 +264,12 @@ func (s *AlwaysGetAdapter[ListInput, ListOutput, GetInput, GetOutput, ClientStru for _, input := range newGetInputs { p.Go(func(ctx context.Context) error { - // Ignore the error here as we don't want to stop the whole process - item, _ := s.GetFunc(ctx, s.Client, scope, input) + item, err := s.GetFunc(ctx, s.Client, scope, input) + if err != nil { + // Don't cache individual errors as they are cheap to re-run + stream.SendError(WrapAWSError(err)) + } if item != nil { s.cache.StoreItem(item, s.cacheDuration(), ck) stream.SendItem(item) diff --git a/adapters/kms-key_test.go b/adapters/kms-key_test.go index 2fb45bf2..9a604d63 100644 --- a/adapters/kms-key_test.go +++ b/adapters/kms-key_test.go @@ -89,6 +89,7 @@ func TestKMSGetFunc(t *testing.T) { } func TestNewKMSKeyAdapter(t *testing.T) { + t.Skip("This test is currently failing due to a key that none of us can read, even with admin permissions. I think we will need to speak with AWS support to work out how to delete it") config, account, region := adapterhelpers.GetAutoConfig(t) client := kms.NewFromConfig(config) From e12ea3c955db1e3a95b055970861a9e58086a8f6 Mon Sep 17 00:00:00 2001 From: Dylan Ratcliffe Date: Mon, 9 Dec 2024 16:22:02 +0000 Subject: [PATCH 2/2] Align tests to new expectations --- adapterhelpers/always_get_source_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adapterhelpers/always_get_source_test.go b/adapterhelpers/always_get_source_test.go index 67280038..b408e85a 100644 --- a/adapterhelpers/always_get_source_test.go +++ b/adapterhelpers/always_get_source_test.go @@ -254,8 +254,8 @@ func TestAlwaysGetSourceList(t *testing.T) { lgs.ListStream(context.Background(), "foo.bar", false, stream) stream.Close() - if len(errs) != 0 { - t.Fatalf("expected 0 error, got %v", len(errs)) + if len(errs) != 6 { + t.Fatalf("expected 6 error, got %v", len(errs)) } if len(items) != 0 { @@ -429,8 +429,8 @@ func TestAlwaysGetSourceSearch(t *testing.T) { lgs.SearchStream(context.Background(), "foo.bar", "id", false, stream) stream.Close() - if len(errs) != 0 { - t.Errorf("expected 0 error, got %v", len(errs)) + if len(errs) != 6 { + t.Errorf("expected 6 error, got %v", len(errs)) } if len(items) != 0 {