fix(dns): narrow Google DNS delete record inputs#473
Open
Jorel97 wants to merge 2 commits into
Open
Conversation
Contributor
Greptile SummaryThis PR tightens the
Confidence Score: 5/5The 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
Sequence DiagramsequenceDiagram
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
Reviews (2): Last reviewed commit: "fix(dns): throw on unavailable Google DN..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #454.
deleteRecord()now narrows the parsedrecordIdpieces before using them and stores the first matching record in a local variable before reading itsttl. 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 typecheckin this projectless workspace because the full dependency checkout is not present here.