From d1a6ab0eb93e715bcb6efe46d658a1a275c555fe Mon Sep 17 00:00:00 2001 From: maximilize <3752128+maximilize@users.noreply.github.com> Date: Tue, 21 Jul 2026 11:55:47 +0200 Subject: [PATCH] plugin/auto: fix inverted arguments in duplicate-origin warning (#8317) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The warning added in #8216 passed the skipped file where the kept file belongs and vice versa, so it logged "using instead of " — the reverse of what Walk actually does. Swap the arguments (and use cleanPath for both) so the message names the file that is being used. Strengthen TestWalkWarnsForDuplicateOrigin to assert the direction; it only checked that both names appeared, so the inversion passed before. Signed-off-by: maximilize <3752128+maximilize@users.noreply.github.com> --- plugin/auto/walk.go | 2 +- plugin/auto/walk_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugin/auto/walk.go b/plugin/auto/walk.go index 5a46682bd..58f469c20 100644 --- a/plugin/auto/walk.go +++ b/plugin/auto/walk.go @@ -43,7 +43,7 @@ func (a Auto) Walk() error { cleanPath := filepath.Clean(path) if previous, ok := seen[origin]; ok && previous != cleanPath { - log.Warningf("Multiple zone files match origin %q: using %q instead of %q", origin, path, previous) + log.Warningf("Multiple zone files match origin %q: using %q instead of %q", origin, previous, cleanPath) toDelete[origin] = false return nil } diff --git a/plugin/auto/walk_test.go b/plugin/auto/walk_test.go index 8e9024325..6d67e6aee 100644 --- a/plugin/auto/walk_test.go +++ b/plugin/auto/walk_test.go @@ -141,6 +141,15 @@ func TestWalkWarnsForDuplicateOrigin(t *testing.T) { t.Fatalf("Expected log to contain %q, got %q", want, got) } } + // The warning must name the kept (first, live) file in the "using" slot and + // the skipped backup in the "instead of" slot — not the other way around. + // Walk keeps example.org.zone (visited first) and skips the .bak file. + if !strings.Contains(got, `example.org.zone" instead of "`) { + t.Errorf("Warning names the wrong file as used; want the live zone in the \"using\" slot, got %q", got) + } + if strings.Contains(got, `example.org.zone.bak-20260528" instead of "`) { + t.Errorf("Warning claims the skipped backup is being used, got %q", got) + } logBuf.Reset() a.Walk()