test(dns): pin zero through the wire format and the zone file - #233
Merged
Conversation
`priority`, `weight` and `port` are nullable because most record types do not carry them, and every place that reads them uses `?? 0` rather than `?: 0` -- correctly, since a zero the caller set is not a zero the caller omitted. MX priority 0 is the highest priority a mail exchange can be given, and RFC 2782 gives all three SRV fields a meaning at zero. Nothing held that. The MX and SRV cases in `RecordTest` use 10 and 5/10/5060, and the zone fixtures use 10, 20 and 50, so `?? 0` could become `?: ''` and only the zone export broke -- silently, into a line `File::parseRdata` then refuses, which fails the import of the whole zone rather than the one record. Covers encode, decode and the zone export/import round trip for MX priority 0 and SRV 0 0 0. Verified red: rewriting the MX branch of `File::formatRdata` to `$pri = $priority ?: ''` exports `mail 300 IN MX mail` and fails the round trip test. Found while tracing a report that an MX record with priority 0 could not be added to Appwrite Cloud. The defect was in the console, and this library already handled zero correctly at every layer -- but nothing proved it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Benchmark resultsdns — transport throughput (4 cores, 250 repeats x 20 workers x 3 domains per transport)
Shared CI runners — treat absolute numbers as rough, compare modes within a run. Commit 6fe4f12. |
Meldiron
commented
Sep 8, 2026
Meldiron
left a comment
Contributor
Author
There was a problem hiding this comment.
lgtm, just tests
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.
Reopened here from utopia-php/dns#51, which the mirror bot closed — development for
packages/dnshappens in this repository. Rewritten against the package's current conventions rather than cherry-picked, since the mirror has drifted (declare(strict_types=1), trailing commas,\strlen,assertInstanceOf).Why
Traced from a report that an MX record with priority 0 could not be added to Appwrite Cloud. The defect was in the console, and this library takes zero correctly at every layer — but nothing proved it.
priority,weightandportare nullable because most record types do not carry them. Every place that reads them already uses?? 0, not?: 0— correctly, since a zero the caller set is not a zero the caller omitted. MX priority 0 is the highest priority a mail exchange can be given, and RFC 2782 gives all three SRV fields a meaning at zero: highest priority, no share of the weighted draw, and the port that marks the service unavailable on that target.The existing coverage uses 10 for MX, 5/10/5060 for SRV, and 10, 20 and 50 in the zone fixtures. So
?? 0could become?: ''inFile::formatRdataand only the zone export would break — silently, into a lineFile::parseRdatathen refuses, which fails the import of the entire zone rather than the one record.What this adds
Four cases in
RecordTest— MX priority 0 and SRV 0 0 0, encode and decode — and two inFileTestfor the export/import round trip.bin/monorepo validatepasses, Pint passes.Seen red: rewriting the MX branch of
File::formatRdatato$pri = $priority ?: ''exportsmail\t300\tIN\tMX\t mailand failstestExportAndImportKeepZeroMxPriority.Related
parseInt(priority) || undefinedread a typed0as "not supplied", so the console refused before a request was sent.priority/weight/portwith a bareInteger(), so a negative priority wrote a zone lineFile::parseRdatarefuses. NowRange(0, 65535).🤖 Generated with Claude Code