Skip to content

fix(dns): narrow Google DNS delete record inputs#473

Open
Jorel97 wants to merge 2 commits into
profullstack:masterfrom
Jorel97:codex/fix-googledns-delete-typecheck-454
Open

fix(dns): narrow Google DNS delete record inputs#473
Jorel97 wants to merge 2 commits into
profullstack:masterfrom
Jorel97:codex/fix-googledns-delete-typecheck-454

Conversation

@Jorel97
Copy link
Copy Markdown

@Jorel97 Jorel97 commented May 29, 2026

Fixes #454.

deleteRecord() now narrows the parsed recordId pieces before using them and stores the first matching record in a local variable before reading its ttl. This addresses the strict/noUncheckedIndexedAccess typecheck failures without changing the successful deletion path.

Verification: targeted static inspection of the failing lines. I could not run corepack pnpm --dir packages/dns/googledns typecheck in this projectless workspace because the full dependency checkout is not present here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 29, 2026

Greptile Summary

This PR tightens the deleteRecord function in the Google Cloud DNS provider to satisfy TypeScript's noUncheckedIndexedAccess compiler option without altering the runtime deletion path.

  • Adds a guard on recordId.split('/') so that an empty or missing type/name segment throws a descriptive error instead of silently propagating undefined.
  • Extracts existing[0] into a first variable and adds an explicit narrowing check before reading first.ttl, satisfying the strict index access typecheck.

Confidence Score: 5/5

The change is a targeted type-narrowing fix; the successful deletion path is unchanged and both new guards are additive.

Both additions — the split result guard and the first variable narrowing — are conservative and do not alter the happy path. The !type || !name guard correctly catches malformed record IDs that would previously have reached the API with undefined interpolated into the URL. No existing behavior is removed.

No files require special attention.

Important Files Changed

Filename Overview
packages/dns/googledns/src/index.ts Adds noUncheckedIndexedAccess-safe narrowing in deleteRecord: validates recordId.split('/') result and introduces a first variable guard before reading ttl.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant deleteRecord
    participant listRecords
    participant GoogleDNS API

    Caller->>deleteRecord: deleteRecord(zoneId, recordId, config)
    deleteRecord->>deleteRecord: split recordId → [type, name]
    alt type or name is empty/undefined
        deleteRecord-->>Caller: throw Error("invalid record id")
    end
    deleteRecord->>listRecords: listRecords(zoneId, config)
    listRecords->>GoogleDNS API: GET /rrsets
    GoogleDNS API-->>listRecords: rrsets[]
    listRecords-->>deleteRecord: DnsRecord[]
    deleteRecord->>deleteRecord: "filter by type & name → existing[]"
    alt "existing.length === 0"
        deleteRecord-->>Caller: return (no-op)
    end
    deleteRecord->>deleteRecord: "first = existing[0]"
    alt first is undefined (unreachable after length check)
        deleteRecord-->>Caller: throw Error("matching record unavailable")
    end
    deleteRecord->>GoogleDNS API: POST /changes {deletions: [{name, type, ttl, rrdatas}]}
    alt "res not ok and status !== 404"
        deleteRecord-->>Caller: throw Error("deleteRecord: status")
    end
    deleteRecord-->>Caller: void
Loading

Reviews (2): Last reviewed commit: "fix(dns): throw on unavailable Google DN..." | 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