question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NS1: Single Value Records with no answer raises IndexError

See original GitHub issue

So 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:closed
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yzguycommented, Oct 27, 2017

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 error

Traceback (most recent call last):
  File "/Users/yzguy/Projects/yzguy-octodns/venv/bin/octodns-dump", line 11, in <module>
    sys.exit(main())
  File "/Users/yzguy/Projects/yzguy-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/yzguy/Projects/yzguy-octodns/venv/lib/python2.7/site-packages/octodns/manager.py", line 362, in dump
    source.populate(zone, lenient=lenient)
  File "/Users/yzguy/Projects/yzguy-octodns/venv/lib/python2.7/site-packages/octodns/provider/ns1.py", line 155, in populate
    record = Record.new(zone, name, data_for(_type, record),
  File "/Users/yzguy/Projects/yzguy-octodns/venv/lib/python2.7/site-packages/octodns/provider/ns1.py", line 75, in _data_for_CNAME
    'value': record['short_answers'][0],
IndexError: list index out of range

So 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.

1reaction
yzguycommented, Oct 23, 2017

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

octodns.record.ValidationError: Invalid record test.yzguy.io.
  - missing value(s)

If you specify --lenient it will complete, giving the warning

2017-10-22T20:46:43  [140737049330624] WARNING Record Invalid record test.yzguy.io.
  - missing value(s)

and you’re YAML file will look like this

test:
  type: A

Which would be caught if you applied it with a

 octodns.record.ValidationError: Invalid record test.yzguy.io.
   - missing value(s)
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found