AWS Certificate Manager GetSecret does not return esv1.NoSecretErr when the certificate does not exist
Description
CertificateManager.GetSecret (providers/v1/aws/certificatemanager/certificatemanager.go)
unconditionally wraps any error from getCertificate in a generic fmt.Errorf, never checking
for errCertificateNotFound first. AGENTS.md's documented contract: "Return esv1.NoSecretErr
from GetSecret when the secret is missing. The reconciler depends on this for deletionPolicy."
Three other methods in this exact file — SecretExists, DeleteSecret, and
reimportCertificate — already correctly detect this same not-found condition via
errors.Is(err, errCertificateNotFound); only GetSecret skips the check.
To Reproduce
- Create a
SecretStore/ClusterSecretStoreusing the AWS provider with the Certificate Manager service. - Create an
ExternalSecretreferencing a certificate ARN that does not exist (or was deleted). GetSecretreturns a generic"failed to get certificate ...: ..."error, notesv1.NoSecretErr.
Minimal reproduction (unit test, passes today against providers/v1/aws/certificatemanager):
func TestGetSecret_NotFound(t *testing.T) {
fake := &fakeacm.Client{
GetCertificateFn: func(_ context.Context, _ *acm.GetCertificateInput, _ ...func(*acm.Options)) (*acm.GetCertificateOutput, error) {
return nil, &smithyFakeNotFound{}
},
}
_, err := newProvider(fake).GetSecret(context.Background(), esv1.ExternalSecretDataRemoteRef{
Key: "arn:aws:acm:us-east-1:123456789012:certificate/missing",
})
if errors.Is(err, esv1.NoSecretErr) {
t.Fatal("did not expect esv1.NoSecretErr -- reproduces the bug")
}
}- ESO version:
main - Provider: AWS / Certificate Manager
Expected behavior
GetSecret should return esv1.NoSecretErr when the certificate doesn't exist, matching
SecretExists/DeleteSecret/reimportCertificate in the same file.
Screenshots
N/A
Additional context
Already implemented and tested a fix
Source: external-secrets/external-secrets