dheerajrajjak / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
0 stars 0 forks source link

BatchHttpRequest errors are less useful than individual HttpRequests #169

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
HttpError._get_reason() uses a case-sensitive header lookup, which fails when 
the header is capitalized as is the case for batch requests.

https://code.google.com/p/google-api-python-client/source/browse/apiclient/error
s.py#44

Furthermore, the brief error produced for BatchHttpRequests contains a '\r' 
character without a preceding '\n' thus causing the current line to be 
overwritten by subsequent characters.

The attached script compares the errors produced by an HttpRequest and 
BatchHttpRequest when trying to create a pre-existing Cloud Storage bucket.

Original issue reported on code.google.com by yova...@google.com on 24 Jul 2012 at 12:15

Attachments:

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 84c1ea7c1fe6.

Original comment by jcgregorio@google.com on 25 Jul 2012 at 3:32

GoogleCodeExporter commented 8 years ago
The bad_errors_issue.py script still shows less information in the batch case.

Specifically, it would be nice to get the 
  "You already own this bucket. Please select another name."
message in the batch error.

Adding print statements to 
  https://code.google.com/p/google-api-python-client/source/browse/apiclient/http.py#1125
reveals that the desired message is available to BatchHttpRequest.

Original comment by yova...@google.com on 25 Jul 2012 at 3:47

GoogleCodeExporter commented 8 years ago
Did you run this against head? I'm see the exact same information running that 
script.

Original comment by jcgregorio@google.com on 25 Jul 2012 at 4:00

GoogleCodeExporter commented 8 years ago
I synced my checkout of the client library, and it does appear to contain your 
changes if that's what you're asking.

The batch request yields:
<HttpError 403 when requesting 
https://www.googleapis.com/storage/v1beta1/b?alt=json returned "Forbidden">

while an individual request gets:
<HttpError 403 when requesting 
https://www.googleapis.com/storage/v1beta1/b?alt=json returned "You already own 
this bucket. Please select another name.">

Original comment by yova...@google.com on 25 Jul 2012 at 4:06

GoogleCodeExporter commented 8 years ago
Interesting, you should only get the following type of message if the JSON 
error message wasn't able to be parsed:

  <HttpError 403 when requesting https://www.googleapis.com/storage/v1beta1/b?alt=json returned "Forbidden">

Can you try commenting out the try: and except: around line 45 of 
apiclient.errors.py and see why the JSON isn't being parsed?

Original comment by jcgregorio@google.com on 25 Jul 2012 at 4:12

GoogleCodeExporter commented 8 years ago
That try statement doesn't get executed in the batch case. For some reason my 
batch requests yield a capitalized 'Content-Type' header, so it doesn't pass 
this if statement

    if self.resp.get('content-type', '').startswith('application/json'):

Original comment by yova...@google.com on 25 Jul 2012 at 4:17

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 21b17d8feb57.

Original comment by jcgregorio@google.com on 26 Jul 2012 at 2:02

GoogleCodeExporter commented 8 years ago
Ah, that's fundamentally a bug in httplib2, which I just committed a fix for, 
but I have also worked around that issue and make the parsing code more robust 
in this change:

  http://codereview.appspot.com/6447045/

Original comment by jcgregorio@google.com on 26 Jul 2012 at 2:31

GoogleCodeExporter commented 8 years ago
That did the trick; thanks.

Original comment by yova...@google.com on 27 Jul 2012 at 4:16