Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(pki): keep gcp project in sync with stored zone

bernie-ge5bebac1fa56
diff --git a/backend/src/services/certificate-authority/acme/dns-providers/gcp-cloud-dns.test.ts b/backend/src/services/certificate-authority/acme/dns-providers/gcp-cloud-dns.test.ts
index 117520f503..10d2175e2a 100644
--- a/backend/src/services/certificate-authority/acme/dns-providers/gcp-cloud-dns.test.ts
+++ b/backend/src/services/certificate-authority/acme/dns-providers/gcp-cloud-dns.test.ts
@@ -171,6 +171,22 @@ describe("gcpCloudDnsDeleteTxtRecord", () => {
);
});
+ it("re-reads and retries when another challenge removed its value first", async () => {
+ getMock
+ .mockResolvedValueOnce(existingRecordSet(['"token-a"', '"token-b"']))
+ .mockResolvedValueOnce(existingRecordSet(['"token-a"']));
+ postMock.mockRejectedValueOnce(axiosError(412)).mockResolvedValueOnce({ data: {} });
+
+ await gcpCloudDnsDeleteTxtRecord(connection, ZONE, RECORD, '"token-a"');
+
+ expect(postMock).toHaveBeenCalledTimes(2);
+ expect(postMock).toHaveBeenLastCalledWith(
+ `${ZONE_URL}/changes`,
+ { deletions: [{ name: FQDN, type: "TXT", ttl: 60, rrdatas: ['"token-a"'] }] },
+ expect.anything()
+ );
+ });
+
it("is a no-op when the record set or value is already gone", async () => {
getMock.mockRejectedValueOnce(axiosError(404)).mockResolvedValueOnce(existingRecordSet(['"token-b"']));
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaFields/GcpCloudDnsZoneFields.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaFields/GcpCloudDnsZoneFields.tsx
index dfb594d4bb..4d44405b80 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaFields/GcpCloudDnsZoneFields.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaFields/GcpCloudDnsZoneFields.tsx
@@ -77,7 +77,7 @@ export const GcpCloudDnsZoneFields = ({ control, connectionId }: Props) => {
name="configuration.dnsProviderConfig.hostedZoneId"
control={control}
render={({ field: { value, onChange }, fieldState: { error } }) => {
- const gcpProjectId = selectedProjectId ?? getProjectIdFromZone(value);
+ const gcpProjectId = getProjectIdFromZone(value) || selectedProjectId || "";
return (
<>