Commit 03b5f06
fix(api-core): handle list-shaped REST error payloads (#18232)
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:
- [x] Make sure to open an issue as a
[bug/issue](https://github.com/googleapis/google-cloud-python/issues)
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (if any source code was changed)
- [x] Appropriate docs were updated (if necessary; no docs change needed
for this bug fix)
Fixes #18223 🦕
## Summary
- Normalize list-shaped REST error payloads to the first dict item
before reading the standard `error` object.
- Preserve existing dict payload behavior and fall back to `unknown
error` when no dict item is present.
- Add unit coverage for list-wrapped error payloads.
## Tests
- `pytest -q tests/unit/test_exceptions.py -k 'http_response or
error_details_from_rest_response'`
- `pytest -q tests/unit/test_exceptions.py`
- `ruff format --check --target-version=py310 --line-length=88
google/api_core/exceptions.py tests/unit/test_exceptions.py`
- `flake8 google/api_core/exceptions.py tests/unit/test_exceptions.py`
- `git diff --check`
## CLA
Google CLA is required by the repository; awaiting the repository's CLA
check on this PR.
Co-authored-by: cyphercodes <cyphercodes@users.noreply.github.com>1 parent a4b442b commit 03b5f06
2 files changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| 513 | + | |
| 514 | + | |
513 | 515 | | |
514 | 516 | | |
515 | 517 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
135 | 160 | | |
136 | 161 | | |
137 | 162 | | |
| |||
0 commit comments