NS1: Single Value Records with no answer raises IndexError
See original GitHub issueSo just dumping our zone, got this error. We had a PTR record in our forward zone in NS1, no idea why, but it also had no answers.
Response from NS1
PTR, {u'domain': u'asmith.net', u'short_answers': [], u'link': None, u'ttl': 3600, u'tier': 1, u'type': u'PTR', u'id': u'1b05cd7943dde9d3'}
Error
Traceback (most recent call last):
File "/Users/asmith/as-octodns/venv/bin/octodns-dump", line 11, in <module>
sys.exit(main())
File "/Users/asmith/as-octodns/venv/lib/python2.7/site-packages/octodns/cmds/dump.py", line 31, in main
manager.dump(args.zone, args.output_dir, args.lenient, *args.source)
File "/Users/asmith/as-octodns/venv/lib/python2.7/site-packages/octodns/manager.py", line 362, in dump
source.populate(zone, lenient=lenient)
File "/Users/asmith/as-octodns/venv/lib/python2.7/site-packages/octodns/provider/ns1.py", line 156, in populate
record = Record.new(zone, name, data_for(_type, record),
File "/Users/asmith/as-octodns/venv/lib/python2.7/site-packages/octodns/provider/ns1.py", line 76, in _data_for_CNAME
'value': record['short_answers'][0],
IndexError: list index out of range
The record doesn’t make sense, plus why have a record with no answers. I believe this should probably throw a ValidationError with a “No Records” reason.
Also at least for NSOne, it’s another convenience, you don’t have to put the .
in, and it will still put it when you query for it.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Setting Up + Working With The NS1 Python SDK
Log into your NS1 account via the NS1 portal; on the Settings + Users page, create an API key. ... When creating an...
Read more >[PATCH] Make dnspython a submodule.
In no-error, no-data - situations, this parameter determines whether NoAnswer should be - raised or not. If True, NoAnswer is raised.
Read more >CodeBLEU/test_files/Full_Reference_PY.txt ... - GitLab
Generate code as a response to NL questions. ... lst = ['a', 'b', 'c'] >>> i = lst.index('b') # This raises ValueError if...
Read more >Chapter 1 - Course Overview - MIT OpenCourseWare
Here is one solution to the problem which is in the Pythonic functional style. ... 27 We compute the square root of a...
Read more >Installation, Administration, and Reference - IBM
DB2 for z/OS does not provide a migration path to convert indexes from existing text search solutions. After migrating from one version of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So after some poking around. I now realize/understand the change that would need to happen in the NS1 Provider.
Originally I had a PTR record with no answers, which is the same method for CNAME and ALIAS
So before even getting to the
validate
method of octodns/record.py inValueMixin
, it’s failing with my original errorSo at least for NS1, when dumping/nooping it will give the error above if you have a CNAME, ALIAS, or PTR with no answers
I think _data_for_CNAME is the only method that needs this addition, the rest have a
values = []
default, which would get caught during a length check in validation.PR here: First PR here to handle the issues in NS1 Provider: https://github.com/github/octodns/pull/136
This fixes up NS1 to have a default value of None, and assign the answer if one exists in the API Response. This fixes the above issue, and validations will create a better user experience.
All sounds good. I’m working on the change
I have it “working”, just need to fix up the tests/new ones
If you dump it without lenient you get
If you specify
--lenient
it will complete, giving the warningand you’re YAML file will look like this
Which would be caught if you applied it with a