SumoLogic/sumologic-python-sdk

No Details on "400 Client Error"

mariten opened this issue · 4 comments

When the API doesn't return 200, you're using raise_for_status to throw exceptions:

  File "/usr/local/lib/python2.7/site-packages/sumologic/sumologic.py", line 77, in search_job_records
    r = self.get('/search/jobs/' + str(search_job['id']) + '/records', params)
  File "/usr/local/lib/python2.7/site-packages/sumologic/sumologic.py", line 43, in get
    r.raise_for_status()
  File "/usr/local/lib/python2.7/site-packages/requests/models.py", line 825, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request

However, the problem with this is that, particular with 400 Client Error, the return JSON from Sumo indicates what exactly in the request is wrong. However, with this message, we are left with no idea what may be bad within a given request.

For example, if the start time isn't properly formatted when doing a search, the library shows this 400 Client Error but no information that the reason for failure is the timezone formatting.

It would be helpful to all developers, especially those new to Sumo, to add this information in the exception.

I forgot about this. Thank you for reminding me. Will try to get to this
this week.
On Wed, Apr 13, 2016 at 7:59 PM Jeff Case notifications@github.com wrote:

When the API doesn't return 200, you're using raise_for_status to throw
exceptions:

File "/usr/local/lib/python2.7/site-packages/sumologic/sumologic.py", line 77, in search_job_records
r = self.get('/search/jobs/' + str(search_job['id']) + '/records', params)
File "/usr/local/lib/python2.7/site-packages/sumologic/sumologic.py", line 43, in get
r.raise_for_status()
File "/usr/local/lib/python2.7/site-packages/requests/models.py", line 825, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request

However, the problem with this is that, particular with 400 Client Error,
the return JSON from Sumo indicates what exactly in the request is wrong.
However, with this message, we are left with no idea what may be bad within
a given request.

For example, if the start time isn't properly formatted when doing a
search, the library shows this 400 Client Error but no information that
the reason for failure is the timezone formatting.

It would be helpful to all developers, especially those new to Sumo, to
add this information in the exception.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#10

Thanks! 👍

Hi guys. Thanks for fixing this awhile back.

However, it seems that this change hasn't been made available on Pip yet:
https://pypi.python.org/pypi/sumologic-sdk
(Newest available version is 1.3, published in Jan 2016)

Can you guys release a new version on Pip with this change included?

Hi @sumoway can you see my question from 10 days ago?