Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't update records which have datafeeds set (server error: invalid feed pointer) #34

Open
ignatenkobrain opened this issue Jul 15, 2019 · 4 comments

Comments

@ignatenkobrain
Copy link
Contributor

import ns1
api = ns1.NS1(apiKey='[…]')
record = api.loadRecord('cloud.na3.pcigdc.com', 'A')
record.update(ttl=3)

results into

Traceback (most recent call last):
  File "x.py", line 6, in <module>
    record.update(ttl=3)
  File "/usr/lib/python3.7/site-packages/ns1/records.py", line 109, in update
    callback=success, errback=errback, **kwargs)
  File "/usr/lib/python3.7/site-packages/ns1/rest/records.py", line 136, in update
    errback=errback)
  File "/usr/lib/python3.7/site-packages/ns1/rest/resource.py", line 73, in _make_request
    return self._transport.send(type, self._make_url(path), **kwargs)
  File "/usr/lib/python3.7/site-packages/ns1/rest/transport/requests.py", line 60, in send
    resp.text)
ns1.rest.errors.ResourceException: server error: invalid feed pointer

This is happening with 0.9.19 release.

@mburtless
Copy link
Contributor

mburtless commented Jul 15, 2019

I'm having trouble recreating this error in python3.7 using the requests transport. Can you enable verbose logging and print the output (example below)?

import logging
import ns1
logging.basicConfig(level=logging.DEBUG)
config = ns1.Config()
config.createFromAPIKey('[...]')
config['verbosity'] = 5
api = ns1.NS1(config=config)
rec = api.loadRecord('cloud.na3.pcigdc.com', 'A')
rec.update(ttl=3)

Also, can you confirm the configuration on the NS1 side? Is your top level zone pcigdc.com or na3.pcigdc.com?

@ignatenkobrain
Copy link
Contributor Author

DEBUG:ns1.rest.transport.basic:{'User-Agent': 'ns1-python 0.9.19 python 0x50791618 linux', 'X-NSONE-Key': '<redacted>'}
DEBUG:ns1.rest.transport.basic:GET https://api.nsone.net/v1/zones/na3.pcigdc.com/cloud.na3.pcigdc.com/A None
DEBUG:ns1.rest.transport.basic:{'User-Agent': 'ns1-python 0.9.19 python 0x50791618 linux', 'X-NSONE-Key': '<redacted>'}
DEBUG:ns1.rest.transport.basic:POST https://api.nsone.net/v1/zones/na3.pcigdc.com/cloud.na3.pcigdc.com/A {"zone": "na3.pcigdc.com", "domain": "cloud.na3.pcigdc.com", "type": "A", "ttl": 3}
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/ns1/rest/transport/basic.py", line 82, in send
    resp = opener.open(request, timeout=self._timeout)
  File "/usr/lib64/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib64/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "x.py", line 10, in <module>
    rec.update(ttl=3)
  File "/usr/lib/python3.7/site-packages/ns1/records.py", line 109, in update
    callback=success, errback=errback, **kwargs)
  File "/usr/lib/python3.7/site-packages/ns1/rest/records.py", line 136, in update
    errback=errback)
  File "/usr/lib/python3.7/site-packages/ns1/rest/resource.py", line 73, in _make_request
    return self._transport.send(type, self._make_url(path), **kwargs)
  File "/usr/lib/python3.7/site-packages/ns1/rest/transport/basic.py", line 88, in send
    handleProblem(resp.code, resp, body)
  File "/usr/lib/python3.7/site-packages/ns1/rest/transport/basic.py", line 77, in handleProblem
    body=msg)
ns1.rest.errors.ResourceException: server error, status code: 400: invalid feed pointer

Yes, changing configuration using web interface works.

@mburtless
Copy link
Contributor

Trouble with recreating was on my end, sorry about that.

I can recreate the issue via curl, so it's looking like this is not a bug with the python module, but with the API itself. This issue occurs when a POST call is made whose body does not explicitly include the answer, meta and full value of the defined metadata type for any answer that has a datafeed set.

I've created a bug internally so NS1's backend team can take a look at this. Will follow up when I have more info on progress there.

@mburtless
Copy link
Contributor

mburtless commented Jul 17, 2019

As an update here, this has been accepted as a bug with the API by NS1's backend team and has been added to their backlog. I'll close this issue out once that has been completed.

In the mean time, the record can still be updated as long as the full answer that has the datafeed defined is included with the update. So the workaround here would be to include the answers returned by loadRecord as a parameter toupdate. I.e:

import logging
import ns1
logging.basicConfig(level=logging.DEBUG)
config = ns1.Config()
config.createFromAPIKey('[...]')
config['verbosity'] = 5
api = ns1.NS1(config=config)
rec = api.loadRecord('cloud.na3.pcigdc.com', 'A')
rec.update(ttl=3, answers=rec.data['answers'])

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

No branches or pull requests

2 participants