Skip to content

Raise ARES_ENODATA when convert_result has no matching records#254

Merged
bdraco merged 2 commits into
masterfrom
fix/convert-result-nodata-raise
May 20, 2026
Merged

Raise ARES_ENODATA when convert_result has no matching records#254
bdraco merged 2 commits into
masterfrom
fix/convert-result-nodata-raise

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented May 20, 2026

What do these changes do?

convert_result used to return [] whenever the answer section had no records matching the requested qtype (NOERROR/NODATA, or only records of other types). For CNAME, SOA, and PTR that crashed callers reading .name, .cname, or .nsname; for the other qtypes it silently diverged from the pycares 4.x raise on NODATA contract this compat layer is meant to preserve. It now raises DNSError(ARES_ENODATA), and _query_callback routes that through set_exception. ANY is unchanged.

Are there changes in behavior for the user?

Yes; query() for qtypes other than ANY will raise aiodns.error.DNSError(ARES_ENODATA) on NODATA answers instead of returning an empty list or, for CNAME/SOA/PTR, crashing the caller with AttributeError. Matches the pycares 4.x behaviour.

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

NOERROR/NODATA responses for non-ANY qtypes used to silently return []
from convert_result. For CNAME/SOA/PTR that crashed callers reading
.name/.cname/.nsname; for A/AAAA/MX/NS/TXT/SRV/NAPTR/CAA it diverged
from the pycares 4.x raise-on-NODATA contract this compat layer is
meant to preserve.

convert_result now raises DNSError(ARES_ENODATA) on empty/no-matching
answers, and _query_callback routes that through set_exception. ANY
stays list-shaped as before.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (08c1e45) to head (df6b477).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #254      +/-   ##
==========================================
+ Coverage   98.42%   98.46%   +0.03%     
==========================================
  Files           5        5              
  Lines        1399     1433      +34     
  Branches       73       74       +1     
==========================================
+ Hits         1377     1411      +34     
  Misses         16       16              
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented May 20, 2026

confirmed report and fix

double checked against pycares 4.x and aiodns 3.

behavior now matches

@bdraco bdraco marked this pull request as ready for review May 20, 2026 01:44
@bdraco bdraco merged commit bca5e10 into master May 20, 2026
24 checks passed
@bdraco bdraco deleted the fix/convert-result-nodata-raise branch May 20, 2026 01:44
@bdraco bdraco mentioned this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant