diff --git a/packages/dns/googledns/src/index.ts b/packages/dns/googledns/src/index.ts index dbb4c535..2c156fd2 100644 --- a/packages/dns/googledns/src/index.ts +++ b/packages/dns/googledns/src/index.ts @@ -124,13 +124,20 @@ export default defineDns({ const project = config.projectId ?? _secret('GOOGLE_PROJECT_ID'); if (!project) throw new Error('GOOGLE_PROJECT_ID not set'); const [type, name] = recordId.split('/'); + if (!type || !name) { + throw new Error('Google Cloud DNS deleteRecord: invalid record id'); + } // Need to fetch the rrset to get current rrdatas for the deletion entry. const existing = (await this.listRecords(zoneId, config)).filter( r => r.type === type && (r.name === name || r.name === name.replace(/\.$/, '')), ); if (existing.length === 0) return; const fqdn = name.endsWith('.') ? name : `${name}.`; - const ttl = existing[0].ttl; + const first = existing[0]; + if (!first) { + throw new Error('Google Cloud DNS deleteRecord: matching record unavailable'); + } + const ttl = first.ttl; const res = await fetch(`${API}/projects/${project}/managedZones/${zoneId}/changes`, { method: 'POST', headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },