Skip to content

sql: also lowercases the zone in record names - #91

Merged
msimerson merged 3 commits into
mainfrom
zone-record-name-case
Oct 16, 2026
Merged

msimerson merged 3 commits into
mainfrom
zone-record-name-case

Conversation

@msimerson

@msimerson msimerson commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

sql/upgrade/07 (#88) lowercased zone names, but not the record names that spell them. 2.x stores @ as "<zone>." in the zone's own case, so after 07 a record could read BandL-horizon.com. inside zone bandl-horizon.com. My local snapshot had 48 of these.

Who notices:

  • powerdns-pipe matches (nt_zone_id, name) exactly in SQL, so it never answered for those names.
  • The web UI's ownerForZone and unqualifyHost compare with endsWith exactly, so it showed the wrong owner.
  • dns-nameserver's other publishers go through ownerFqdn(), which lowercases, so they weren't affected.

3.x has no releases yet, so this extends 07 rather than adding an 08. After rewriting the zones, 07 now makes two record rewrites:

  • Absolute names: the zone part takes the zone's new spelling. The host keeps its case (WWW.Example.com. becomes WWW.example.com.), and the match stops at a label boundary, so notExample.com. is left alone.
  • Bare names equal to the zone: Example.com becomes the zone.

Both compare the lowercased record name with the zone as stored. A live zone that 07 leaves in capitals, because another live zone has the same name, therefore keeps records that still match it. A separate 08 would have lowercased those records regardless.

07 is still idempotent. NicTool/NicTool#373's upgrade 2.42 makes the same rewrite. sql/schema.test.js covers an apex name, a host name, a bare name, a relative name, a name just outside the zone, an already canonical name, a record in a skipped zone, and a re-run.

07 lowercased zone names, but 2.x stored '@' as "<zone>." in the zone's
own case, so records still spelled the old name: BandL-horizon.com. in
zone bandl-horizon.com. powerdns-pipe matches record names exactly, so
it never found them, and the web UI showed the wrong owner. 08 rewrites
the zone part of absolute names, keeping the host's case, and a bare
name equal to the zone. NicTool 2.42 does the same rewrite.
3.x has no releases, so 07 can still change. In one upgrade the record
rewrite follows the zone rewrite and compares with the zone as stored,
so a live zone 07 leaves in capitals keeps records that match it; a
separate 08 lowercased those records regardless.
@msimerson msimerson changed the title sql: give record names that spell their zone its lowercase spelling sql: 07 also lowercases the zone in record names Oct 16, 2026
@msimerson
msimerson requested a balanced review from Copilot October 16, 2026 05:17

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.

🟢 Approval recommended

No blocking issues were identified in the focused migration and regression coverage; database-backed tests were not run.

0 open findings

What changed in this PR

Extends migration 07 to normalize the zone portion of existing record names for exact-match consumers.

Changes:

  • Rewrites absolute and zone-equal bare names while preserving host case and skipped zones.
  • Adds regression coverage, including migration reruns.
  • Updates the changelog.
File Description
sql/​upgrade/​07_lowercase_zone_names.sql Adds zone-aware record-name rewrites.
sql/​schema.test.js Tests normalization, exclusions, and idempotency.
CHANGELOG.md Documents the expanded migration.

🧠 Review effort: Balanced


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

@msimerson
msimerson merged commit 21f35ca into main Oct 16, 2026
14 checks passed
@msimerson
msimerson deleted the zone-record-name-case branch October 16, 2026 05:20
@msimerson msimerson changed the title sql: 07 also lowercases the zone in record names sql: also lowercases the zone in record names Oct 16, 2026
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