Skip to content

fix(dns): stop dns set from wiping zones via the v3 replace-record PUT - #143

Merged
jpage-godaddy merged 3 commits into
rust-portfrom
dns-set-zone-wipe-fix
Jul 22, 2026
Merged

jpage-godaddy merged 3 commits into
rust-portfrom
dns-set-zone-wipe-fix

Conversation

@jpage-godaddy

@jpage-godaddy jpage-godaddy commented Jul 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • dns set's "replace" reconcile called PUT /v3/domains/zones/{zone}/dns-records/{recordId} to update an existing record in place. That route responds 200 but doesn't perform a single-record replace as its description promises — it silently replaces the entire record collection with the system records plus whatever's in the request body, discarding every other record in the zone. Reproduced live against a test zone; see gddy dns set wipes the entire zone — issues a PUT to a non-existent v3 dns-records endpoint that the API executes as a full-collection replace #136.
  • dns set now reconciles the "replace" case as create-the-new-value-then-delete-the-old-record: if the create fails, the old record is left untouched, so a failure can never touch more than the record actually being written. The vendored v3 spec, the merged domains.oas3.json, and the embedded API catalog no longer expose the PUT operation at all.
  • The create-then-delete reconcile is a no-op when the record being replaced already holds the desired value (e.g. re-running the same set, or only some of several --data values actually changed) — otherwise that create would fail against v3's exact-duplicate DUPLICATE_RECORD since the old record hasn't been deleted yet. (Caught in Copilot review.)
  • Also addresses feat(dry-run): let dry-run validate input and preview real effects #141 (comment): dns delete --dry-run's preview now reports "nothing to delete" on a zero-match instead of the misleading "would delete".

Test plan

  • cargo test (344 passed)
  • cargo clippy -- -D warnings
  • cargo fmt --check
  • Live smoke test against a test zone: seeded a name with 2 overlapping records plus unrelated CNAME/TXT/A records elsewhere in the zone, ran dns set --dry-run then for real — only the targeted name's records changed, everything else in the zone survived (this is the exact scenario that used to wipe the zone).
  • Live smoke test for the idempotent no-op case: ran dns set twice with the same --data value — second run reports replaced: 1 with no failure instead of an exact-duplicate error.

Co-authored-by: Claude Sonnet 5 noreply@anthropic.com

jpage-godaddy and others added 2 commits July 22, 2026 10:52
`PUT /v3/domains/zones/{zone}/dns-records/{recordId}` responds 200 but
doesn't perform a single-record replace as its description promises —
it silently replaces the entire record collection with the system
records plus whatever's in the request body, discarding everything
else in the zone (reproduced live against a test zone; see
#136).

`dns set`'s "replace" reconcile action now creates the new value and
only deletes the record it's replacing once that create has succeeded,
so a failed create never touches the old record. The vendored v3 spec,
the merged domains.oas3.json, and the embedded API catalog no longer
expose the PUT operation at all, so it can't be reintroduced by
accident or invoked directly via `gddy api call`.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
`action: "would delete"` read oddly when nothing matched (0 records,
0 deletes) — the preview now reports `"nothing to delete"` in that
case instead of implying a delete with no target.

Addresses #141 (comment)

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

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.

Pull request overview

This PR hardens dns set against a destructive v3 API behavior where a purported single-record PUT .../dns-records/{recordId} can silently replace the entire zone’s record collection. It removes that unsafe operation from the generated/embedded API surfaces and changes dns set “replace” reconciliation to a safer create-then-delete sequence, plus a small dry-run UX fix for dns delete.

Changes:

  • Reworked dns set replace reconciliation to create the new record value first, then delete the old record (never issuing the v3 PUT).
  • Improved dns delete --dry-run messaging to report "nothing to delete" when no records match.
  • Removed the v3 replaceDNSRecord PUT operation from the vendored OpenAPI specs and the embedded API catalog (and adjusted endpoint counts accordingly).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rust/src/dns/set.rs Stops using the unsafe v3 replace-record PUT and implements replace as create-then-delete, with additional reporting/test updates.
rust/src/dns/delete.rs Tweaks dry-run preview "action" to clearly indicate the zero-match case.
rust/schemas/api/manifest.json Updates Domains API endpoint count after removing the PUT operation.
rust/schemas/api/domains.json Removes the PUT replace-record operation from the embedded API catalog.
rust/domains-client/src/lib.rs Removes tests referring to the replace-record PUT behavior.
rust/domains-client/openapi/swagger_domains.v3.yaml Removes the put operation and adds an explicit safety note explaining why.
rust/domains-client/openapi/domains.oas3.json Removes the PUT replace-record operation from the merged OAS3 spec.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/src/dns/set.rs Resolved
`apply_replace` always created the new value before deleting the old
record, but when the old record already holds the desired data (e.g.
re-running the same `set`, or only some of several values actually
changed), that create hits v3's exact-duplicate `DUPLICATE_RECORD`
since the old record hasn't been deleted yet — failing an operation
that had nothing to do. Short-circuit as a no-op success when the old
record's current value already matches the desired one.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

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.

3 participants