Commit 00b9040
authored
fix(api_core): clarify misleading http 404 unimplemented error message (#17681)
### **Summary of the issue:**
**Context:**
When a gRPC call fails with grpc.StatusCode.UNIMPLEMENTED but the error
details string includes "Received http2 header with status: 404", the
google-api-core library currently translates this into
google.api_core.exceptions.MethodNotImplemented. This scenario often
happens due to client-side configuration errors like an incorrect
api_endpoint or a malformed resource path, not because the method is
actually unimplemented.
**Actual Behavior:**
The library raises google.api_core.exceptions.MethodNotImplemented: 501
Received http2 header with status: 404. This exception is misleading
because the primary issue indicated by the underlying error is related
to the 404 (Not Found), not that the method is unimplemented (501). This
makes debugging difficult for users.
**Expected Behavior:**
google-api-core should raise an exception that better reflects the
underlying HTTP 404. Suggested improvements:
Prioritize the 404 status when present in the details, raising
google.api_core.exceptions.NotFound (404).
The goal is to provide a more actionable error message to the user,
guiding them to check the endpoint or resource path.
Fixes b/3624387221 parent 7c18c24 commit 00b9040
2 files changed
Lines changed: 31 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
26 | 24 | | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
657 | 656 | | |
658 | 657 | | |
659 | 658 | | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
660 | 670 | | |
661 | 671 | | |
662 | | - | |
| 672 | + | |
663 | 673 | | |
664 | 674 | | |
665 | 675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
393 | 394 | | |
394 | 395 | | |
395 | 396 | | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
0 commit comments