fix: require a TXT record before a service is considered complete - #1821
Conversation
|
|
Rebase with requested adjustmentsBranch Changes applied
Not changed (and why)
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1821 +/- ##
=======================================
Coverage 99.81% 99.81%
=======================================
Files 33 33
Lines 3759 3763 +4
Branches 533 534 +1
=======================================
+ Hits 3752 3756 +4
Misses 5 5
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
Rebase with requested adjustmentsBranch Changes applied
Not changed (and why)
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
|
|
|
Note No code changes since the last review ( |
38d9fff to
ab25924
Compare
Rebase with requested adjustmentsBranch Changes applied
Not changed (and why)
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
|
|
RFC 6763 section 6 requires every DNS-SD service to have a TXT record. ServiceInfo.text defaults to an empty bytes object, so the `self.text is not None` guard in _is_complete never failed and a service with addresses but no TXT record resolved as complete. Track whether TXT data has actually been seen — either supplied by the caller or received in a DNSText record — so an empty TXT record still completes the service while a missing one does not.
ab25924 to
7f2bec6
Compare
Rebase with requested adjustmentsBranch Changes applied
Not changed (and why)
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
|
We don't have NSEC support for anything here so its out of scope. If someone asks for it, it could be added in the future, but I don't think any real server does that |
PR Review — fix: require a TXT record before a service is considered completeMerge-ready. The last open item from the previous round is closed; only the maintainer-side deferred note remains. What's solid, verified by reading the code at this head commit:
🟢 Suggestions
1. [Deferred] TXT-less and NSEC-denying responders now burn the full request timeout
|
Summary
RFC 6763 §6 requires every DNS-SD service to have a TXT record, but
ServiceInfo._is_completeguarded onself.text is not None— a condition that never fails, since__init__seedsself.text = b"". A service that answered with SRV + A/AAAA but no TXT therefore resolved as fully complete.ServiceInfonow tracks whether TXT data has actually been seen, so an empty TXT record still completes the service while a missing one does not (per @bdraco's note on the issue).Closes #1815
Changes
ServiceInfogains a_txt_seenflag (bintininfo.pxd), seeded from caller-suppliedpropertiesand set when aDNSTextrecord is processed from the network or the cache._is_completechecks_txt_seeninstead of the deadself.text is not Nonetest.AddressResolver{,IPv4,IPv6}override_is_completeand are unaffected.properties == {}; caller-supplied properties → complete;async_requestreturns False until a TXT record arrives, then True.Two deliberate scoping decisions worth a maintainer's eye:
propertiescount as TXT data, mirroring how caller-suppliedaddressesalready satisfy the address half of_is_complete. Without this, pre-seeding aServiceInfowith known data and callingrequest()to refresh would block for the full timeout._get_address_and_nsec_records()puts missing types in the bitmap where RFC 4034 §4.1.2 / RFC 6762 §6.1 put the existing ones — so it is left out of this fix.Test plan
poetry run pytest --durations=20 --timeout=60 tests→ 451 passed, 2 skipped (no pre-existing tests needed changing).master(assert True is Falseon the no-TXT cache load) and pass with the fix.ruff,ruff-format,mypy,flake8,codespell,cython-lintpre-commit hooks pass.cython -3 -I src src/zeroconf/_services/info.pytranspiles cleanly with the new.pxddeclaration (no new warnings). The C compile itself could not be exercised — this sandbox has no Python headers — so CI's wheel build is the real check on that.Quality Report
Changes: 3 files changed, 164 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (4 PASSED)
Branch hygiene: clean
Generated by Kōan