rbw / aiosnow

Asynchronous ServiceNow Library
MIT License
74 stars 12 forks source link

Invalid check response error #42

Closed sulbig closed 4 years ago

sulbig commented 4 years ago

I changed my password today and forgot to update my related .env variable, then ran into the following issue.

The HTTP response body was...

{"error":{"message":"User Not Authenticated","detail":"Required to provide Auth information"},"status":"failure"}

Which led to...

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/...project-path.../hello.py", line 58, in main
    incidents = await unresolved(app)
  File "/...project-path.../hello.py", line 43, in unresolved
    incidents = await r.get(selection)
  File "/...project-path.../venv/lib/python3.8/site-packages/snow/resource/__init__.py", line 170, in get
    return await self.reader.collect(
  File "/...project-path.../venv/lib/python3.8/site-packages/snow/request/helpers/read.py", line 21, in collect
    _, content = await GetRequest(self.resource, query=selection, **kwargs).send()
  File "/...project-path.../venv/lib/python3.8/site-packages/snow/request/core/get.py", line 16, in send
    return await self._send(**kwargs)
  File "/...project-path.../venv/lib/python3.8/site-packages/snow/request/core/base.py", line 102, in _send
    content = await response.get_content()
  File "/...project-path.../venv/lib/python3.8/site-packages/snow/request/core/base.py", line 36, in get_content
    if "error" in content:
TypeError: argument of type 'NoneType' is not iterable

It appears the async def get_content(self) method of the Response class is checking for "error" in the content variable, which is None because the content = ujson.loads(body).get("result") just before it is selecting the "result" key -- not "error" key.

sulbig commented 4 years ago

I submitted pull request #43 for this issue. I am not experienced with Git/Github, so please point out if I have not done something correctly.

rbw commented 4 years ago

Cool, thanks. I'll take a look shortly.