Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

bisgardo
Copy link
Contributor

@bisgardo bisgardo commented Apr 27, 2024

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 "...").

@bisgardo bisgardo force-pushed the derivative branch 2 times, most recently from ad57eb3 to 7c01f98 Compare April 28, 2024 20:06
@bisgardo bisgardo changed the base branch from main to cleanup April 28, 2024 20:06
@bisgardo bisgardo changed the title Use crate 'derivative' to derive 'Debug' trait Include function parameters in error messages Apr 28, 2024
@bisgardo bisgardo marked this pull request as ready for review April 28, 2024 20:45
Base automatically changed from cleanup to main April 29, 2024 09:43
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 "...").
Copy link
Contributor

@soerenbf soerenbf left a 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!(
Copy link
Contributor

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"))]

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?

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants