Skip to content

zone_record: PUT merges onto the stored record - #77

Open
aberoham wants to merge 3 commits into
NicTool:mainfrom
aberoham:zone-record-partial-put
Open

aberoham wants to merge 3 commits into
NicTool:mainfrom
aberoham:zone-record-partial-put

Conversation

@aberoham

@aberoham aberoham commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

On mysql, ZoneRecord.put() passed RFC field names straight to the UPDATE. Changing exchange on an MX record, sending the whole record back, or changing the type failed with an unknown column. Only fields that are also column names, such as ttl, could be edited.

put() now merges the change onto the stored record, packs it with the same map as create(), and writes only the columns whose value changed. Packing the merged record matters where fields share a column. NAPTR keeps flags, service and regexp in address, so changing regexp alone keeps the other two. Concurrent edits of different columns don't undo each other. Concurrent edits of fields packed into one column still can.

A type change drops the old type's rdata on both stores, using each type's rdataFields. On mysql that clears every column the old type used, including description for NAPTR, IPSECKEY, NSEC and NXT. The file stores used to keep the old fields beside the new ones.

A type change, or a change to a field packed into one column such as an SOA serial, must leave a valid record, checked with the RR class as create() does. { type: 'MX' } on an A record now answers 400, and so does a create with bad rdata. On mysql the change only applies to the type it was merged against, so a type change in between answers 409.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Type-only updates can persist invalid records, and packed-field concurrent updates can still overwrite each other.

3 open findings
What changed in this PR

Updates zone-record PUT behavior to merge RFC fields correctly across MySQL and file stores.

Changes:

  • Packs merged records before MySQL updates.
  • Removes obsolete RDATA during type changes.
  • Adds broad PUT regression coverage.
File Description
CHANGELOG.md Documents corrected PUT behavior.
lib/​zone_record/​store/​base.js Adds shared RDATA field discovery.
lib/​zone_record/​store/​file.js Clears old RDATA during type changes.
lib/​zone_record/​store/​mysql.js Merges and maps updates to database columns.
lib/​zone_record/​test/​index.js Tests partial updates and type changes.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/zone_record/store/file.js Outdated
Comment thread lib/zone_record/store/mysql.js Outdated
Comment thread lib/zone_record/store/mysql.js Outdated
Copilot spotted that a type-only PUT, such as A to MX, saved an MX with
no preference or exchange. A PUT that changes the type, or a field
packed into one column such as an SOA serial, now checks the merged
record with the RR class and answers 400, as a bad create now does too.
A type change also clears legacy weight, priority and other. On mysql
the UPDATE writes only real columns, every rdata column on a type
change, applies only to the type it was merged against, and answers 409
when the row changed in between. A NULL column no longer reads back as
a null RR field.
@aberoham
aberoham force-pushed the zone-record-partial-put branch from 1b8a637 to 9ec3e0a Compare October 14, 2026 22:37
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.

2 participants