Skip to content

fix(dns): validate googledns delete record ids#481

Open
sevencat2004 wants to merge 2 commits into
profullstack:masterfrom
sevencat2004:fix/googledns-delete-record-typecheck
Open

fix(dns): validate googledns delete record ids#481
sevencat2004 wants to merge 2 commits into
profullstack:masterfrom
sevencat2004:fix/googledns-delete-record-typecheck

Conversation

@sevencat2004
Copy link
Copy Markdown

Fixes #454.

Summary:

  • validate Google DNS record IDs before splitting them into type/name parts
  • narrow the first matched record before reading ttl under noUncheckedIndexedAccess
  • keep the existing no-op behavior when no matching record exists

Validation:

  • corepack pnpm --dir packages/dns/googledns typecheck
  • corepack pnpm vitest run packages/dns/googledns/src/index.test.ts
  • git diff --check

Submitted for the ugig bounty/gig: Need someone to test submit bugs and PRs to fix those bugs.

Solana wallet for bounty payout:
Dy4yMkjCfupxaURt6iTMUrxqSDEmAJPPkKF66QahxJZD

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 30, 2026

Greptile Summary

This PR hardens the deleteRecord method in the Google Cloud DNS plugin by validating the recordId string before splitting on /, throwing a descriptive error for malformed IDs. It also narrows the existing[0] array access to a named variable to satisfy TypeScript's noUncheckedIndexedAccess compiler flag.

  • Validation rejects IDs with no /, an empty type segment (leading /), or an empty name segment (trailing /), matching the expected "<type>/<FQDN>" format generated by listRecords.
  • The early-return no-op when no matching record exists is preserved; firstRecord.ttl replaces the previously unchecked existing[0].ttl access.

Confidence Score: 5/5

Safe to merge — the change adds a targeted guard in one function with no regressions to existing call paths.

The validation logic correctly handles all malformed recordId edge cases (missing separator, empty type, empty name), the firstRecord narrowing is a straightforward TypeScript correctness fix, and the no-op early-return behavior is fully preserved. No other code paths in the file are touched.

No files require special attention.

Important Files Changed

Filename Overview
packages/dns/googledns/src/index.ts Adds recordId validation in deleteRecord and narrows existing[0] access for noUncheckedIndexedAccess compatibility — logic is correct and existing behavior is preserved

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[deleteRecord called\nzoneId, recordId, config] --> B[Get access token\n& project ID]
    B --> C{recordId valid?\nseparatorIndex check}
    C -- invalid --> D[throw Error:\ninvalid record id]
    C -- valid --> E[slice type & name\nfrom recordId]
    E --> F[listRecords → filter\nby type & name]
    F --> G{firstRecord\nexists?}
    G -- no --> H[return no-op]
    G -- yes --> I[Build FQDN\nread firstRecord.ttl]
    I --> J[POST /changes\ndeletions = all rrdatas]
    J --> K{res.ok or 404?}
    K -- no --> L[throw Error:\nHTTP status]
    K -- yes --> M[done]
Loading

Reviews (2): Last reviewed commit: "fix(dns): preserve googledns file encodi..." | Re-trigger Greptile

Comment thread packages/dns/googledns/src/index.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dns-googledns fails strict typecheck in deleteRecord

1 participant