-
Notifications
You must be signed in to change notification settings - Fork 318
Closed
Milestone
Description
When an invalid API key is used, the library doesn't return a standard JSON error and the error thrown never indicates that the reason is the key, only that the server's 403 response is invalid JSON.
For example:
from datadog import initialize, api
options = {
'api_key': 'this is not a key',
'app_key': 'this is not a key'
}
initialize(**options)
title = "Something big happened!"
text = 'And let me tell you all about it here!'
foo = api.Event.create(title=title, text=text)
Throws:
Traceback (most recent call last):
File "test.py", line 14, in <module>
foo = api.Event.create(title=title, text=text, tags=tags)
File "/usr/local/lib/python2.7/site-packages/datadog/api/events.py", line 61, in create
return super(Event, cls).create(attach_host_name=True, **params)
File "/usr/local/lib/python2.7/site-packages/datadog/api/resources.py", line 46, in create
attach_host_name=attach_host_name, **params)
File "/usr/local/lib/python2.7/site-packages/datadog/api/api_client.py", line 143, in submit
raise ValueError('Invalid JSON response: {0}'.format(content))
ValueError: Invalid JSON response: <html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>
Is this a regression? The docs seem to indicate that a JSON error message (e.g. {errors: ['403 Forbidden']}) would be returned.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels