Repository: kubernetes-sigs/external-dns

Issue:
Warning for “*” label still emitted by FindZone() after fix in #5685
<!--
Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!

Make sure to validate the behavior against latest release https://github.com/kubernetes-sigs/external-dns/releases as we don't support past versions.
-->

**What happened**:
After the merge of PR #5685 , the warning log for labels containing the `*` character (e.g., `*.example.com`) was resolved in some parts of the codebase by updating the IDNA profile. However, [`provider.ZoneIDName.FindZone()`](https://github.com/kubernetes-sigs/external-dns/blob/1b9d7cddc0f7c0a5a3b3bae0abcf0de57cd558cf/provider/zonefinder.go#L44-L71) still uses the old IDNA conversion logic, which continues to emit a warning like:
`Failed to convert label “*” of hostname “*.example.com” to its Unicode form: idna: disallowed rune U+002A`

**What you expected to happen**:
Since the warning for `*` was intentionally suppressed in #5685 by adjusting the IDNA profile, I expected the same behavior to be applied consistently across the codebase, including in `FindZone()`.

**How to reproduce it (as minimally and precisely as possible)**:
Use a domain like `*.example.com` in a test or real configuration and observe that `FindZone()` still logs a warning due to the `*` character.

<!--
Please provide as much detail as possible, including Kubernetes manifests with spec.status, ExternalDNS arguments, and logs. A bug that cannot be reproduced won't be fixed.
-->

**Anything else we need to know?**:
It’s possible that the omission of `FindZone()` from the changes in #5685 was intentional, but it seems more likely to have been missed. To help clarify, I’ve submitted a small PR to address the remaining use of the outdated IDNA logic, in case the fix is desired: [#5705](https://github.com/kubernetes-sigs/external-dns/pull/5705)

Happy to adjust or close the PR depending on whether this behavior is intentional or not.


**Environment**:

- External-DNS version (use `external-dns --version`): `latest main` (post-#5685, pre-release)
- DNS provider: Original log was observed when using CloudDNS
- Others: N/A


Hints from issue comments:
@ivankatliarchuk: Pr merged 
/close@k8s-ci-robot: @ivankatliarchuk: Closing this issue.

<details>

In response to [this](https://github.com/kubernetes-sigs/external-dns/issues/5706#issuecomment-3145577799):

>Pr merged 
>/close


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
</details>

Solution patch:
diff --git a/provider/zonefinder.go b/provider/zonefinder.go
index 08e6b316..a529e17e 100644
--- a/provider/zonefinder.go
+++ b/provider/zonefinder.go
@@ -20,7 +20,8 @@ import (
 	"strings"
 
 	log "github.com/sirupsen/logrus"
-	"golang.org/x/net/idna"
+
+	"sigs.k8s.io/external-dns/internal/idna"
 )
 
 type ZoneIDName map[string]string
@@ -48,7 +49,7 @@ func (z ZoneIDName) FindZone(hostname string) (string, string) {
 		if strings.Contains(label, "_") {
 			continue
 		}
-		convertedLabel, err := idna.Lookup.ToUnicode(label)
+		convertedLabel, err := idna.Profile.ToUnicode(label)
 		if err != nil {
 			log.Warnf("Failed to convert label %q of hostname %q to its Unicode form: %v", label, hostname, err)
 			convertedLabel = label



Test patch:
diff --git a/provider/zonefinder_test.go b/provider/zonefinder_test.go
index 4eddd36c..b02a0388 100644
--- a/provider/zonefinder_test.go
+++ b/provider/zonefinder_test.go
@@ -34,6 +34,7 @@ func TestZoneIDName(t *testing.T) {
 	z.Add("123123", "_metadata.example.com")
 	z.Add("1231231", "_foo._metadata.example.com")
 	z.Add("456456", "_metadata.エイミー.みんな")
+	z.Add("123412", "*.example.com")
 
 	assert.Equal(t, ZoneIDName{
 		"123456":  "qux.baz",
@@ -42,6 +43,7 @@ func TestZoneIDName(t *testing.T) {
 		"123123":  "_metadata.example.com",
 		"1231231": "_foo._metadata.example.com",
 		"456456":  "_metadata.エイミー.みんな",
+		"123412":  "*.example.com",
 	}, z)
 
 	// simple entry in a domain
@@ -83,8 +85,12 @@ func TestZoneIDName(t *testing.T) {
 	assert.Equal(t, "_foo._metadata.example.com", zoneName)
 	assert.Equal(t, "1231231", zoneID)
 
+	zoneID, zoneName = z.FindZone("*.example.com")
+	assert.Equal(t, "*.example.com", zoneName)
+	assert.Equal(t, "123412", zoneID)
+
 	hook := testutils.LogsUnderTestWithLogLevel(log.WarnLevel, t)
-	_, _ = z.FindZone("???")
+	_, _ = z.FindZone("xn--not-a-valid-punycode")
 
-	testutils.TestHelperLogContains("Failed to convert label \"???\" of hostname \"???\" to its Unicode form: idna: disallowed rune U+003F", hook, t)
+	testutils.TestHelperLogContains("Failed to convert label \"xn--not-a-valid-punycode\" of hostname \"xn--not-a-valid-punycode\" to its Unicode form: idna: invalid label", hook, t)
 }