Skip to content

Conversation

@vinay-google
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1279 🦕

@vinay-google vinay-google requested a review from a team as a code owner April 3, 2021 05:52
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 3, 2021
Fixes googleapis#1279

We have been using [errors.py](https://github.com/googleapis/google-api-python-client/blob/master/googleapiclient/errors.py) to raise HttpError errors. Unfortunately, many of our instances have content that matches the following format:
```
{
  error: {
    errors: {
    }
  }
}
```
versus what [_get_reason](https://github.com/googleapis/google-api-python-client/blob/master/googleapiclient/errors.py#L64) is looking for i.e. only one of `detail`, `details`, or `message`
This results us seeing the errors being logged but not the details:

```
<HttpError 503 when requesting url returned "Internal error. Please try again.">
```

The solution involves modifying [_get_reason](https://github.com/googleapis/google-api-python-client/blob/master/googleapiclient/errors.py#L64) to also support `error_detail_keyword` with an additional value of `errors`. This modifies the order to: `detail`, `details`, `errors`, `message`
@vinay-google vinay-google changed the title Adds support for errors.py to also use 'errors' for error_details feat: Adds support for errors.py to also use 'errors' for error_details Apr 3, 2021
@parthea parthea added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 3, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 3, 2021
Copy link
Contributor

@parthea parthea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the fix @vinay-google!

@parthea parthea added the automerge Merge the pull request once unit tests and other checks pass. label Apr 3, 2021
@gcf-merge-on-green gcf-merge-on-green bot merged commit a5d2081 into googleapis:master Apr 3, 2021
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Apr 3, 2021
gcf-merge-on-green bot pushed a commit that referenced this pull request Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

errors.py: Add support for JSON content that has errors instead of detail or details

3 participants