You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(dns): replace records in place with dns set and confirm the final result - #359
gddy dns set now replaces each record it keeps with a single in-place update, instead of creating the new value and then deleting the old record.
Safer replace. A replaced record keeps its ID, and a TTL-only change is one call. If an update fails, the existing record is left as it was; it can no longer end up with both the old and new value at the name.
unchanged count. A record that already matches what you asked for is reported as unchanged and left alone, so running the same set twice changes nothing the second time. replaced no longer includes these. Anything parsing set's JSON will see replaced drop and a new unchanged field. The dry-run preview reports the same.
Matching follows how the API stores records. Names and hostname targets (CNAME, ALIAS, MX, SRV, HTTPS, SVCB) are compared without case or a trailing dot, and CAA data and TLSA hex without case, so Example.COM matches a stored example.com.. Values the API keeps as written (TXT text, AAAA addresses, HTTPS/SVCB parameters, SRV service and protocol) are compared exactly. This PR also uses the same comparison for the final check.
TTL is kept. A replaced record keeps its current TTL unless you pass --ttl. Previously it was reset to 3600.
Result lists the records. The output includes the records now at the type and name, with their IDs and TTLs, as read back after the change.
Final check. After writing, set reads the type and name back and fails if the records there are not the ones you asked for, for example because someone else changed them while it ran. The error lists what is extra and what is missing (with TTLs when --ttl was given) and nothing is removed.
--ttl validated up front for dns add and dns set: 600 to 86400 seconds, from the API spec. Out-of-range values fail locally with a clear message instead of an API error.
Full SRV/TLSA names are rejected by add and set.--name _sip._tcp.chat could create a record at a nested name nobody asked for, or move an existing record there, because the API composes the DNS name from the record's name plus its service and protocol. Both commands now refuse it before any request and name the --name and flags to use instead. list and delete still accept either form, since they only look records up.
Required flags are checked up front. MX, SRV, HTTPS and SVCB need --priority; SRV also needs --weight, --port, --service and --protocol; TLSA needs --port and --protocol as well as usage, selector and matching type. A missing one is reported with the other missing flags before login, instead of as a 400 from the API.
--service and --protocol take the plain name.--service sip --protocol tcp and --service _sip mean the same thing: the underscore DNS requires is added when it is left off, and a value that cannot be a label is rejected with an example. Records are shown in the underscore form (--fields service,protocol, or JSON), since that is the DNS name.
CAA --flag defaults to 0. The API requires a flag on CAA records, so dns add/dns set without --flag used to fail. An omitted flag now means 0 (non-critical).
set still reconciles per record, so it is not atomic across a whole set: creates and deletes remain separate calls, and a mid-run failure is reported per record. A concurrent change between the initial read and the writes cannot be prevented (the API has no conditional writes); the final check reports it instead.
cargo check --workspace, cargo clippy --workspace -- -D warnings, cargo fmt --check, cargo test --workspace (1271 tests in the main crate) and ./rust/scripts/check-module-size.sh all pass.
Run live against a throwaway zone in the test environment:
re-running an identical set reported everything unchanged, including a CNAME given as Example.COM and a CAA record given without --flag;
--ttl retimed records, and an omitted --ttl kept the stored TTL;
a second writer adding a record mid-run was reported by the final check, and the record was left in place;
CNAME conflicts with --replace-conflicting-types worked in both directions.
SRV records: a replace in place (new data, new name, and no change at all) now succeeds, including at the zone apex; the API returned a 500 for every one of those until it was fixed on the DNS side. A composed-name set is refused with the record untouched, and a plain --service sip --protocol tcpset reports a stored _sip/_tcp record as unchanged.
Not verified against production. The change relies on the API's replace operation, and the fixes to it for SRV, behaving the same there as in the test environment. ALIAS could only be covered by a unit test: the test environment's API rejects it on write. TLSA is covered by unit tests only, because the test zone has no DNSSEC and so a TLSA record cannot be created there.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Final-state verification can miss changes to case-sensitive values and return stale record metadata, while inconsistent content comparisons cause unnecessary updates on repeated runs.
Updates dns set to replace individual records in place and verify the resulting record set, replacing the create/delete approach introduced after #136.
Changes:
Restores single-record PUT updates, preserves existing TTLs when omitted, and reports unchanged records separately.
Adds final-state verification and includes records with IDs in successful output.
Validates TTLs locally and updates tests and customer guidance.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Hostname normalization omits ALIAS records, causing canonical read-backs to fail verification and subsequent runs to issue unnecessary replacements instead of reporting unchanged.
Include all differing fields in verification errors
rust/src/dns/set/verify.rs:72
When an explicit TTL differs on read-back, both mismatch lists show the same record label, hiding the reason verification failed. service and protocol are also compared but omitted from the labels. Include those fields and, when compare_ttl is true, the requested and stored TTLs so the error identifies what needs correcting.
Also addressed the finding in the latest review body ("Include all differing fields in verification errors") in 2e58c15: the final-check error now labels records with SRV service/protocol and, when --ttl was passed, the requested and stored TTLs, so a TTL-only mismatch no longer prints two identical lines.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
An omitted CAA flag is not normalized to zero, causing matching read-back records to report a final-state mismatch and preventing subsequent runs from recognizing them as unchanged.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Normalize omitted CAA flag to zero when comparing records
rust/src/dns/records.rs:401
CAA's optional --flag is left absent in the desired record, so a read-back containing the non-critical value flag: 0 compares unequal even when all other fields match. This makes an omitted-flag dns set --type CAA --tag issue report a final-state mismatch and prevents subsequent runs from treating that record as unchanged. Normalize an omitted CAA flag to zero for comparison, and add a regression test for an omitted-flag request against a flag-zero read-back.
Addressed the finding in the latest review body ("Normalize omitted CAA flag to zero") in 4d9b558. It turned out to be a bigger problem than the comparison: with no --flag, the CLI sent no flag at all and the API rejects that ("flag is required for CAA records"), so dns add/dns set for CAA only worked with --flag passed. An omitted --flag now defaults to 0, so it is accepted and a repeat set reports the record as unchanged. Confirmed against the test zone.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The re-enabled PUT previously caused whole-zone data loss, and test-only verification plus a final check limited to targeted records leave production safety requiring human confirmation.
…te (#360)
## What changes for users
SRV and TLSA records can now be found by the name they are listed under in `gddy dns list`, `dns set` and `dns delete`.
Before, the API's name filter only understood a composed name (`_service._proto.name` for SRV, `_port._proto.name` for TLSA), while a record is listed under its short name. So with an SRV record `chat` in place:
- `dns list <domain> --type SRV --name chat` returned nothing.
- `dns delete <domain> --type SRV --name chat` reported `deleted: 0`, exited successfully, and left the record in place.
- `dns set` could not see existing records, so it tried to create a duplicate and failed, or (with the in-place `set` in #359) created a new record and then reported it as missing.
Now the CLI fetches records of the type and matches the name itself, ignoring case. Either form of the name works:
- **Short name** (`--name chat`): every SRV record listed under `chat`, whatever its service. For TLSA, every port.
- **Full name** (`--name _sip._tcp.chat`, or `_443._tcp.www` for TLSA): only that service's (or port's) record. At the zone apex the full name has no suffix (`_sip._tcp`). This form keeps working as it did before, including in the commands the CLI suggests when a record already exists.
- If a record is listed under exactly the name given, only that name's records are selected, so `chat` and a record literally named `_sip._tcp.chat` stay separate owners and a delete by one cannot reach the other.
**Behavior to be aware of:** `dns delete --type SRV --name chat` removes every SRV record listed under `chat`. That is what the command says, but it used to remove nothing for these types. The guide says so, shows the full-name form for targeting one service, and recommends `--dry-run` first.
## `dns set` no longer deletes the record you asked to keep
For SRV, `dns set` could delete the target you asked to keep: with `chat` holding `a.example.com.` and `b.example.com.`, `set --data b.example.com` left only `a.example.com.`. The API stores hostname targets with a trailing dot, the pairing compared text exactly, so the request matched the wrong record, failed as a duplicate, and the cleanup then deleted the one that was meant to stay.
Records are now compared the way the API holds them: names and hostname targets (CNAME, ALIAS, MX, SRV, HTTPS, SVCB) without case or a trailing dot, CAA data and TLSA hex without case, and values it keeps as written (TXT, AAAA, HTTPS/SVCB parameters, SRV service and protocol) exactly. #359, which is stacked on this PR, builds on the same comparison. A regression test fails without it.
## Under the hood
- The change is in the shared record fetch, so no new flags are needed. Other record types still filter by name on the server.
- With no `--name` there is nothing to match, so those lists are unchanged.
- #359 reads records back after a `set`, so it relies on this lookup finding SRV and TLSA records.
- The record helper tests moved to their own file (`records_tests.rs`), which the repository's file-size limit requires.
## Also in this PR
- Adds DNS and domains reviewers to `reviewers.json` (and regenerates `CODEOWNERS`, which the drift check requires). This is a separate commit.
## Verification
- `cargo check --workspace`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --check`, `cargo test --workspace` (1172 tests in the main crate) and `./rust/scripts/check-module-size.sh` all pass.
- New unit tests cover SRV and TLSA matching by short and full name, apex names, the two-owner case, other types still filtering on the server, and the `set` regression above.
- Run live against a throwaway zone in the test environment, with SRV:
- `list --name <name>` finds the record (it returned nothing before) and a name that doesn't exist returns nothing;
- the full name selects one service, and deleting by it left the other service's record in place;
- `delete --dry-run` finds records and `delete` removes them (`deleted: 1`);
- `set` creating a new SRV record creates it, and the `a`/`b` case above now keeps `b.example.com.`;
- the apex form (`_sip._tcp`) finds and deletes an apex SRV record.
- **TLSA is covered by unit tests only.** The test zone has no DNSSEC, so a TLSA record could not be created. The API spec describes the same composed name, so the same behavior is expected.
- Adding an apex SRV record returns a 400 from the API but still creates the record. That is an API problem and is not changed here.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
The reason will be displayed to describe this comment to others. Learn more.
Listing accepts both short and composed forms via listed_name_matches, but this check does not, so a composed-name set can write and then fail verification, or never report unchanged. This should treat short and composed names as equal here.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you were right that this was a real hole, though I took the fix in a different direction than the one you suggested. I reproduced it: with a record stored as rts, a set using the composed name _sip._tcp.rts found it through listed_name_matches (as you say), and then the update wrote the composed string back as the record's name, so the record was quietly moved to a nested name and the final check could not match it.
Treating the two names as equal in the final check would have let that rename pass without complaint, so instead dns set (and dns add, which had the same problem) now reject a full SRV/TLSA name up front, before any request, and say which --name and --service/--protocol to use. list and delete still accept both forms, since they only look records up. Fixed in 0d3d856; I confirmed on the test zone that the composed-name set is refused with a validation error and the existing record is left untouched.
… result
`dns set` now replaces each record it keeps with a single in-place update
instead of creating the new value and then deleting the old record. A
replaced record keeps its ID, a TTL-only change is one call, and a failed
update leaves the existing record untouched rather than leaving two values
at the name.
- Records that already match what you asked for are reported as
`unchanged` and left alone, so running the same `set` twice changes
nothing the second time. The result gains an `unchanged` count and
`replaced` no longer includes them.
- A replaced record keeps its current TTL unless you pass `--ttl`.
- The result lists the records now in place, including their IDs.
- After writing, `set` reads the type and name back and fails if the
records there are not the ones you asked for, for example because
someone else changed them while it ran. It lists what is extra and what
is missing and removes nothing.
- `--ttl` is checked up front for both `dns add` and `dns set`: 600 to
86400 seconds.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`dns set` now judges whether a record already matches, and whether the
final read-back matches, using one comparison that follows how the API
stores each field, so re-running `set` with `Example.COM` for a CNAME that
is stored as `example.com.` reports it unchanged instead of replacing it
again.
- Hostnames (CNAME, MX, SRV, HTTPS, SVCB targets) and record names are
compared without case or a trailing dot; CAA data and TLSA certificate
hex are compared without case.
- Values the API keeps as written are compared exactly: TXT text, AAAA
addresses, HTTPS/SVCB parameters, and SRV service and protocol. A
concurrent change in case there is now caught by the final check.
- The records in the result come from the final read-back, so the IDs and
TTLs shown are what is in the zone, not what each write returned.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ield in dns set errors
- An ALIAS record's target is compared the way a CNAME's is, without case or
a trailing dot, so `set` leaves a matching ALIAS alone instead of
replacing it on every run.
- When the final check finds records that are not the ones requested, each
one is labelled with its SRV service and protocol, and with its TTL when
`--ttl` was given, so a TTL-only difference no longer shows two identical
lines.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The API requires a flag on every CAA record, but `--flag` was optional and
left unset when omitted, so adding or setting a CAA record without it
failed with "flag is required for CAA records". An omitted `--flag` now
means 0 (non-critical), which is also what an existing record without an
explicit flag is stored as, so running the same `set` again reports the
record as unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…check required flags up front
For SRV and TLSA records the API composes the DNS name from the record's name and
its service and protocol (or port and protocol). Giving `--name` as the full name
(`_sip._tcp.chat`) could create a record at a nested name nobody asked for with
`dns add`, or move an existing record with `dns set`. Both now reject it before
any request and say which `--name` and flags to use.
The flags each record type needs are now checked when the arguments are parsed,
instead of after login with a 400 from the API:
- MX, SRV, HTTPS and SVCB need `--priority`; SRV also needs `--weight`, `--port`,
`--service` and `--protocol`; TLSA needs `--port` and `--protocol` in addition
to its usage, selector and matching type.
- `--service` and `--protocol` take the plain name (`sip`, `tcp`); the leading
underscore DNS requires is added when it is left off, and a value that cannot
be a label is rejected with an example.
- Where they are shown (`--fields service,protocol`, or JSON) they appear in the
underscore form, since that is the DNS name.
The DNS guide describes the required flags per record type.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
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.
What changes for users
gddy dns setnow replaces each record it keeps with a single in-place update, instead of creating the new value and then deleting the old record.unchangedcount. A record that already matches what you asked for is reported asunchangedand left alone, so running the samesettwice changes nothing the second time.replacedno longer includes these. Anything parsingset's JSON will seereplaceddrop and a newunchangedfield. The dry-run preview reports the same.Example.COMmatches a storedexample.com.. Values the API keeps as written (TXT text, AAAA addresses, HTTPS/SVCB parameters, SRV service and protocol) are compared exactly. This PR also uses the same comparison for the final check.--ttl. Previously it was reset to 3600.setreads the type and name back and fails if the records there are not the ones you asked for, for example because someone else changed them while it ran. The error lists what is extra and what is missing (with TTLs when--ttlwas given) and nothing is removed.--ttlvalidated up front fordns addanddns set: 600 to 86400 seconds, from the API spec. Out-of-range values fail locally with a clear message instead of an API error.addandset.--name _sip._tcp.chatcould create a record at a nested name nobody asked for, or move an existing record there, because the API composes the DNS name from the record's name plus its service and protocol. Both commands now refuse it before any request and name the--nameand flags to use instead.listanddeletestill accept either form, since they only look records up.--priority; SRV also needs--weight,--port,--serviceand--protocol; TLSA needs--portand--protocolas well as usage, selector and matching type. A missing one is reported with the other missing flags before login, instead of as a 400 from the API.--serviceand--protocoltake the plain name.--service sip --protocol tcpand--service _sipmean the same thing: the underscore DNS requires is added when it is left off, and a value that cannot be a label is rejected with an example. Records are shown in the underscore form (--fields service,protocol, or JSON), since that is the DNS name.--flagdefaults to 0. The API requires a flag on CAA records, sodns add/dns setwithout--flagused to fail. An omitted flag now means 0 (non-critical).Under the hood
gddy dns setwipes the entire zone — issues a PUT to a non-existent v3 dns-records endpoint that the API executes as a full-collection replace #136). The generator rule and the test that pinned its removal are replaced by a test that fails if the operation goes missing.setstill reconciles per record, so it is not atomic across a whole set: creates and deletes remain separate calls, and a mid-run failure is reported per record. A concurrent change between the initial read and the writes cannot be prevented (the API has no conditional writes); the final check reports it instead.cleanupoutcome from fix(dns): change a retained record's TTL by delete-then-create in dns set #352, which the in-place update makes unnecessary.main), which is what lets the final check see them after aset.Verification
cargo check --workspace,cargo clippy --workspace -- -D warnings,cargo fmt --check,cargo test --workspace(1271 tests in the main crate) and./rust/scripts/check-module-size.shall pass.gddy dns setwipes the entire zone — issues a PUT to a non-existent v3 dns-records endpoint that the API executes as a full-collection replace #136 failure did not reproduce);setreported everything unchanged, including a CNAME given asExample.COMand a CAA record given without--flag;--ttlretimed records, and an omitted--ttlkept the stored TTL;--replace-conflicting-typesworked in both directions.setis refused with the record untouched, and a plain--service sip --protocol tcpsetreports a stored_sip/_tcprecord as unchanged.ALIAScould only be covered by a unit test: the test environment's API rejects it on write. TLSA is covered by unit tests only, because the test zone has no DNSSEC and so a TLSA record cannot be created there.🤖 Generated with Claude Code