AWS Certificate Manager GetSecret does not return esv1.NoSecretErr when the certificate does not exist

Author: wankhede04Created Sep 22, 2026Updated Sep 22, 2026
Labelskind/bugtriage/pending-triage

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

  1. Create a SecretStore/ClusterSecretStore using the AWS provider with the Certificate Manager service.
  2. Create an ExternalSecret referencing a certificate ARN that does not exist (or was deleted).
  3. GetSecret returns a generic "failed to get certificate ...: ..." error, not esv1.NoSecretErr.

Minimal reproduction (unit test, passes today against providers/v1/aws/certificatemanager):

go
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