plugin/test: fix TXT record comparison logic for multi-string vs multi-record scenarios#7413
Merged
yongtang merged 1 commit intocoredns:masterfrom Jul 15, 2025
Merged
Conversation
…cords This fixes an issue where the test plugin failed to distinguish between: - a single TXT record split into multiple 255-byte chunks - multiple separate TXT records with single chunks The logic now joins TXT chunks for both actual and expected records before comparison, ensuring semantic correctness per RFC 1035 and avoiding false positives. Fixes coredns#7404 Signed-off-by: Syed Azeez <syedazeez337@gmail.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7413 +/- ##
==========================================
+ Coverage 55.70% 59.77% +4.07%
==========================================
Files 224 273 +49
Lines 10016 18037 +8021
==========================================
+ Hits 5579 10781 +5202
- Misses 3978 6624 +2646
- Partials 459 632 +173 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
yongtang
approved these changes
Jul 15, 2025
|
Thank you @syedazeez337 |
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.
Summary
This PR fixes a subtle but important bug in the
testplugin of CoreDNS where TXT record assertions failed to correctly distinguish between:The result was inaccurate test validations — either false positives or failures — especially in cases where long TXT records were involved.
Problem Description
In DNS, a single TXT record may be split into multiple substrings due to the 255-byte limit. For example:
This is one TXT record, not two.
The
testplugin previously compared TXT records using raw[]stringslices fromdns.TXT.Txt, like:This caused incorrect results when:
len(Txt) > 1), andSolution
The comparison logic has been updated to:
strings.Join(...)Example Fix:
Additional Changes
plugin/test/testdata/txtrecordsplit.testRunTestFileintestdata_test.goto enable isolated testinggo fmtandgolangci-lintwith no issuesImpact
This improves the reliability of the
testplugin when verifying TXT records, especially in cases involving long or split TXT strings. It ensures future plugin development or zone file testing behaves consistently with DNS standards.Related Issue
Fixes #7404