-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Some failed request do not return any body element resulting in a unclear error message
For example an API Request to an intersight instance with self signed certs results return a {"changed": false, "msg": "API error: 'body' "}
A request to a non existent domain "bogus.intersight.com" also returns a:
{"changed": false, "msg": "API error: 'body' "}
The problematic code is at intersight.py 186ff
try:
response, info = self.intersight_call(**options)
if not re.match(r'2..', str(info['status'])):
raise RuntimeError(info['status'], info['msg'], info['body'])
except Exception as e:
self.module.fail_json(msg="API error: %s " % str(e))
Those 2 Errors do not return a "body" value => resulting in a KeyError.
A possible fix would be to exclude the "info['body']" from the RuntimeError statement or use info.get('body', '') instead.
Metadata
Metadata
Assignees
Labels
No labels