Skip to content

HETZNER: gracefully handle FQDN labels when listing records#3859

Merged
tlimoncelli merged 1 commit intoStackExchange:mainfrom
das7pad:hetzner-fqdn-listing
Dec 1, 2025
Merged

HETZNER: gracefully handle FQDN labels when listing records#3859
tlimoncelli merged 1 commit intoStackExchange:mainfrom
das7pad:hetzner-fqdn-listing

Conversation

@das7pad
Copy link
Copy Markdown
Collaborator

@das7pad das7pad commented Nov 30, 2025

This PR is gracefully handling FQDN labels when listing records from the Hetzner DNS Control api.

These records can be created via other tools or the browser UI.

Testing:

diff --git a/providers/hetzner/types.go b/providers/hetzner/types.go
index 964f1b7b..3429acc2 100644
--- a/providers/hetzner/types.go
+++ b/providers/hetzner/types.go
@@ -3,2 +3,3 @@ package hetzner
 import (
+       "fmt"
        "strings"
@@ -63,3 +64,3 @@ func fromRecordConfig(in *models.RecordConfig, zone zone) record {
        r := record{
-               Name:   in.GetLabel(),
+               Name:   in.GetLabelFQDN() + ".",
                Type:   in.Type,
@@ -69,2 +70,3 @@ func fromRecordConfig(in *models.RecordConfig, zone zone) record {
        }
+       fmt.Printf("CREATE: %q\n", r.Name)
 
@@ -93,2 +95,3 @@ func toRecordConfig(domain string, r *record) (*models.RecordConfig, error) {
        }
+       fmt.Printf("LISTING: %q\n", r.Name)
        if strings.HasSuffix(r.Name, "."+domain+".") {

Config:

var REG_NONE = NewRegistrar('none')
var DSP = NewDnsProvider("HETZNER")

D('testing1.dev', REG_NONE, DnsProvider(DSP),
  A('@', '127.0.0.1'),
  A('foo', '127.0.0.1')
)

First push:

Waiting for concurrent gathering(s) to complete...LISTING: "@"
LISTING: "@"
LISTING: "@"
LISTING: "@"
CREATE: "foo.testing1.dev."
DONE
******************** Domain: testing1.dev
1 correction (HETZNER)
#1: Batch creation of records:
	+ CREATE A foo.testing1.dev 127.0.0.1 ttl=300
SUCCESS!
Done. 1 corrections.

Second push (no-op):

Waiting for concurrent gathering(s) to complete...LISTING: "@"
LISTING: "@"
LISTING: "@"
LISTING: "@"
LISTING: "foo.testing1.dev."
DONE
******************** Domain: testing1.dev
Done. 0 corrections.

DNS query:

$ dig foo.testing1.dev. @helium.ns.hetzner.de.
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53563
foo.testing1.dev.	300	IN	A	127.0.0.1

Additional testing:

  • update/delete foo when record foo.testing1.dev. exists, works
  • creating foo.testing1.dev is treated as foo.testing1.dev.testing1.dev. in the API, hence the specific suffix check for <dot>DOMAIN<dot>
  • Test with HETZNER_V2, rejects records with FQDN
FAILURE! has dot (.) suffix (invalid_input, 50f9cf872ed8f1f808fd33c25cf88a81)

@tlimoncelli
Copy link
Copy Markdown
Contributor

Very nice!

@tlimoncelli tlimoncelli merged commit c073f2e into StackExchange:main Dec 1, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: short (example.com) is not supposed to end with a dot

3 participants