-
Notifications
You must be signed in to change notification settings - Fork 11
Allow plugins to return error information as query responses #1072
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
base: main
Are you sure you want to change the base?
Conversation
- Add error field to Query schema in protobuf - Add error variant to QueryState in protobuf adjustments made to - hipcheck-common/src/chunk.rs - hipcheck-common/src/types.rs - sdk/rust/src/engine.rs
// An error was encountered while processing. | ||
QUERY_STATE_ERROR = 5; | ||
} |
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.
I don't understand why this needs an additional state variant - "Unspecified" would only be used in an error scenario anyway, it's short for "UnspecifiedError". we can also re-name variants without breaking compatibility, so we could just rename "Unspecified" to "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.
That's correct. I chose to add a new state in the draft version of the PR, mostly because it was easier to distinguish between the new uses (that include an error string) and the old ones (which don't).
Ideally, I'd like to update all existing uses of Unspecified to use error strings. The idea would be to incrementally replace all of them with Error, and finally rename Unspecified to Error when all are converted.
But I wasn't sure if that would end up being too many changes for one PR (both in terms of dev time, and review effort).
// A plugin-generated error string. | ||
// Shall be present if and only if state == QUERY_STATE_ERROR | ||
optional string error = 10; |
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.
Is there a reason we can't re-use an existing field like "key" or "concern" for the error message? Not only does it preserve the existing structure, but we can guarantee "error" can only be treated as an error message when the state matches
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.
It should certainly be possible to re-use an existing field. For my sanity while prototyping the changes, I added a new field to keep it separate.
error
field toQuery
schema in protobuferror: Option<String>
tostruct Query
inhipcheck-common/src/types.rs
QueryState
enum in protobufError
case toPluginResponse
Remaining TODOs
Error: protoc failed: hipcheck.proto: This file contains proto3 optional fields, but --experimental_allow_proto3_optional was not set.
PluginResponse::Error
when appropriate in itsimpl From<Query>
blockhandle_session
passes error responses tosend_session_err
send_session_err
to send error strings instead of just settingQueryState
toUnspecified
QueryState::Unspecified
toQueryState::Error
and pass an error string