fix: fail service resolution fast when nsec denies the needed address types - #1827
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1827 +/- ##
=======================================
Coverage 99.81% 99.81%
=======================================
Files 33 33
Lines 3799 3839 +40
Branches 543 553 +10
=======================================
+ Hits 3792 3832 +40
Misses 5 5
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
e665332 to
41012d1
Compare
There was a problem hiding this comment.
Pull request overview
Adds NSEC-based fast failure when required address families are authoritatively unavailable.
Changes:
- Tracks IPv4 and IPv6 denial state.
- Checks cached and live NSEC records during resolution.
- Adds coverage for resolver variants and denial scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/zeroconf/_services/info.py |
Implements address-family denial handling. |
src/zeroconf/_services/info.pxd |
Adds corresponding Cython declarations. |
tests/services/test_info.py |
Tests cached, live, partial, and reset behavior. |
Suppressed comments (1)
src/zeroconf/_services/info.py:675
- These flags only transition from
FalsetoTrue. If a newer authoritative NSEC for the same host now includes a previously denied family, the old denial remains and can be combined with the new bitmap to make_is_deniedincorrectly report that all requested families are absent. Recompute both flags from every current server NSEC rather than accumulating denials across snapshots.
if _TYPE_A not in rdtypes and not self._ipv4_denied:
self._ipv4_denied = True
updated = True
if _TYPE_AAAA not in rdtypes and not self._ipv6_denied:
self._ipv6_denied = True
updated = True
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
41012d1 to
25efc2e
Compare
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
c9f2cbe to
b9ff66e
Compare
ServiceInfo is a single shot throw away |
b9ff66e to
781b46c
Compare
Agreed, dropping that one. Flags reset at top of |
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
781b46c to
ac3afd2
Compare
PR Review — fix: fail service resolution fast when nsec denies the needed address typesBoth outstanding suggestions from the last round are now covered by tests, and no production code changed since — approving with two cosmetic nits. Specific things done well:
🟢 Suggestions
1. [Pre-Existing Issue] `@cython.locals` for `async_update_records` names locals that don't exist
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
|
Addressed both nits in 0ffc2ed. For the cython.locals one, the suggested The test docstring is now a single line. |
Summary
Follow up to #1825. When an NSEC record at the host name denies every address type a request still needs,
async_requestnow fails fast instead of waiting out the full timeout; RFC 6762 §6.1 makes such an NSEC an authoritative nonexistence assertion.Details
_is_deniedcheck derives the wanted families from_query_record_types, soAddressResolverIPv4,AddressResolverIPv6,AddressResolver, and plainServiceInfoall share one definition with no overrides._load_from_cachealso consults a cached NSEC at the server name when the request is still incomplete, covering the case where the other address family already resolved.Test plan
poetry run pytest testspasses, 480 passedServiceInfo, NSEC and SRV arriving in either order in one batch, denial reset when the SRV target moves, a newer bitmap clearing a stale denial, and NSECs for unrelated names being ignored