Bug 1379267 - multiple KeyError exceptions raised during handling of empty response
Summary: multiple KeyError exceptions raised during handling of empty response
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-dns
Version: 24
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jeffrey C. Ollie
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-26 08:59 UTC by David Howells
Modified: 2016-11-19 21:00 UTC (History)
5 users (show)

Fixed In Version: python-dns-1.15.0-1.fc24 python-dns-1.15.0-1.fc25
Clone Of:
Environment:
Last Closed: 2016-11-11 20:51:27 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github rthalley dnspython issues 206 0 None None None 2016-09-26 15:25:16 UTC

Description David Howells 2016-09-26 08:59:31 UTC
Description of problem:

The following code:

#!/usr/bin/python3
import sys
import dns.resolver;
try:
    print("AFSDB:")
    for AFSDB in dns.resolver.query(sys.argv[1], "AFSDB"):
        print("\t" + str(AFSDB.hostname))
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
    print("Couldn't find any AFSDB records")

when pointed at a place that produces a response with no pertinent answers, eg:

    /data/afs/dnstest.py your-file-system.com

or:

    /data/afs/dnstest.py www.redhat.com

tries to generate a NoAnswer exception, but incurs a KeyError exception whilst trying to do so and then yet another KeyError exception whilst trying to handle that:

warthog>/data/afs/dnstest.py your-file-system.com
AFSDB:
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/dns/resolver.py", line 157, in __init__
    rdclass, rdtype)
  File "/usr/lib/python3.5/site-packages/dns/message.py", line 333, in find_rrset
    raise KeyError
KeyError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/dns/resolver.py", line 167, in __init__
    dns.rdatatype.CNAME)
  File "/usr/lib/python3.5/site-packages/dns/message.py", line 333, in find_rrset
    raise KeyError
KeyError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/afs/dnstest.py", line 6, in <module>
    for AFSDB in dns.resolver.query(sys.argv[1], "AFSDB"):
  File "/usr/lib/python3.5/site-packages/dns/resolver.py", line 1025, in query
    raise_on_no_answer, source_port)
  File "/usr/lib/python3.5/site-packages/dns/resolver.py", line 956, in query
    raise_on_no_answer)
  File "/usr/lib/python3.5/site-packages/dns/resolver.py", line 176, in __init__
    raise NoAnswer(question=response.question)
  File "/usr/lib/python3.5/site-packages/dns/exception.py", line 47, in __init__
    self._check_kwargs(**kwargs)
  File "/usr/lib/python3.5/site-packages/dns/exception.py", line 69, in _check_kwargs
    self.supp_kwargs)
AssertionError: following set of keyword args is required: {'response'}


On the other hand, invoking it with somewhere that has an AFSDB record works fine:

warthog>/data/afs/dnstest.py grand.central.org
AFSDB:
        grand-old-opry.central.org.
        grand.mit.edu.

As does giving it an invalid name:

warthog>/data/afs/dnstest.py grand.central.orgg
AFSDB:
Couldn't find any AFSDB records


Version-Release number of selected component (if applicable):

python3-3.5.1-17.fc24.x86_64
python3-dns-1.12.0GITa4774ee-1.fc24.noarch

Comment 1 David Howells 2016-09-26 09:00:43 UTC
Note that the problem still happens if AFSDB is changed to TXT in the code.

Comment 2 Avram Lubkin 2016-09-26 12:36:38 UTC
This looks like an upstream bug. I tried it with the current git snapshot. Interestingly, NoAnswer was handled correctly, but I was unable to get a response when there should have been one. I think this might be related to the deprecation of the ANY class, but I'm not sure. Can you confirm and file an issue upstream? [1] The plan is to update Fedora with 1.15.0 when it is released.

[1] https://github.com/rthalley/dnspython/issues

Comment 3 David Howells 2016-09-26 14:40:33 UTC
I built the current git top into the Fedora RPM and it doesn't produce an AFSDB record, even for grand.central.org which definitely has one.

However, examples/mx.py from the git tree crashes in the same way as I was seeing with my test program earlier if I make it use python3 but not if it uses python2.

Comment 4 David Howells 2016-09-27 14:05:35 UTC
This is fixed as of commit bb0c9f21f4a6f56f2fe8d7c1fc991080ef89d223 upstream.

Comment 5 Avram Lubkin 2016-09-27 14:16:03 UTC
Thanks for working with upstream. We're expecting 1.15.0 to be released in the near future and will put it out when it become available.

Comment 6 Fedora Update System 2016-10-09 12:29:26 UTC
python-dns-1.15.0-1.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-4998c59ba3

Comment 7 Fedora Update System 2016-10-09 13:50:49 UTC
python-dns-1.15.0-1.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-1857421df6

Comment 8 Fedora Update System 2016-11-11 20:51:27 UTC
python-dns-1.15.0-1.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2016-11-19 21:00:55 UTC
python-dns-1.15.0-1.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.