-
Notifications
You must be signed in to change notification settings - Fork 1
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
Include function parameters in error messages #18
base: main
Are you sure you want to change the base?
Conversation
ad57eb3
to
7c01f98
Compare
For debugging purposes, it's important that error messages include as much relevant information as possible. It's much easier to help a user if they can pass on an accurate error message that they received. But precisely because the messages should be in a form where the user can share it without worrying about leaking secrets (and because such errors may end up in logs that could leak), the messages must not include any confidential data. They should also not be unnecessarily verbose. To implement this, we add the "debug" serialization of the functions' input values to the error message that's returned if the call fails. We use the 'derivative' crate to "redact" fields containing secret or verbose data (i.e. they render as "...").
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.
Nice idea. one minor thing to consider:
|
||
#[test] | ||
fn identity_issuance_request_parameters_debug() { | ||
assert_eq!( |
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 gets very hard (for me at least) to read these very long inline equality checks. Would be nice if we could do something like
let actual = ...;
let expected = ...;
assert_eq(actual, expected); // or assert_eq(format("{:?}", actual), expected);
pub struct GlobalContext { | ||
#[serde(rename = "onChainCommitmentKey")] | ||
pub on_chain_commitment_key_hex: String, | ||
#[derivative(Debug(format_with = "redacted_format"))] |
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.
Are these meant to only mark things that are secret? Or it here because there are a lot of generators?
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 suppose since it is verbose (you mention secret or verbose in the description).
For debugging purposes, it's important that error messages include as much relevant information as possible. It's much easier to help a user if they can pass on an accurate error message that they received.
But precisely because the messages should be in a form where the user can share it without worrying about leaking secrets (and because such errors may end up in logs that could leak), the messages must not include any confidential data.
They should also not be unnecessarily verbose.
To implement this, we add the "debug" serialization of the functions' input values to the error message that's returned if the call fails. We use the 'derivative' crate to "redact" fields containing secret or verbose data (i.e. they render as "...").