Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/dns/googledns/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ export default defineDns<Config>({
const token = await getAccessToken();
const project = config.projectId ?? _secret('GOOGLE_PROJECT_ID');
if (!project) throw new Error('GOOGLE_PROJECT_ID not set');
if (typeof recordId !== 'string' || !recordId.includes('/')) {
throw new Error(`Invalid recordId: ${recordId}. Expected format: "<type>/<FQDN>"`);
}
Comment on lines +126 to +128
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Empty segment edge cases pass validation

recordId.includes('/') accepts values like /example.com. or A/ — both contain a / but produce an empty type or name after the split. An empty type silently matches no records and the function returns without error; an empty name produces fqdn = '.' which is syntactically wrong and may generate a confusing API error. Adding a stricter pattern check would catch these at the validation boundary.

Suggested change
if (typeof recordId !== 'string' || !recordId.includes('/')) {
throw new Error(`Invalid recordId: ${recordId}. Expected format: "<type>/<FQDN>"`);
}
if (typeof recordId !== 'string' || !/^[^/]+\/[^/]+/.test(recordId)) {
throw new Error(`Invalid recordId: ${recordId}. Expected format: "<type>/<FQDN>"`);
}

const [type, name] = recordId.split('/');
// Need to fetch the rrset to get current rrdatas for the deletion entry.
const existing = (await this.listRecords(zoneId, config)).filter(
Expand Down