-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(storage): avoid crashes when parsing ErrorInfo
#8968
fix(storage): avoid crashes when parsing ErrorInfo
#8968
Conversation
Maybe unsurprisingly, the error payloads are less structured that we expected. This PR performs additional validation to avoid crashes while trying to parse these payloads as a `ErrorInfo`. If we could reliably use exceptions I would just parse the code and handle any exception in a single line of code, alas, we cannot.
Google Cloud Build Logs
ℹ️ NOTE: Kokoro logs are linked from "Details" below. |
Codecov Report
@@ Coverage Diff @@
## main #8968 +/- ##
==========================================
- Coverage 94.47% 94.47% -0.01%
==========================================
Files 1421 1421
Lines 124916 124931 +15
==========================================
+ Hits 118012 118024 +12
- Misses 6904 6907 +3
Continue to review full report at Codecov.
|
if (!e.contains("message") || !e.contains("details")) return default_error(); | ||
if (!e["message"].is_string()) return default_error(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could return a Status(code, e.value("message", ""))
if e.contains("message") && e["message"].is_string() && !e.contains("details")
, but it's also fine to return the whole payload as a message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
Maybe unsurprisingly, the error payloads are less structured that we
expected. This PR performs additional validation to avoid crashes while
trying to parse these payloads as a
ErrorInfo
. If we could reliablyuse exceptions I would just parse the code and handle any exception in
a single line of code, alas, we cannot.
Fixes #8965
This change is