-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Some way to influence/adjust error messages to redact certain fields in objects? #1069
Comments
Yeah, this is definitely something I have been wanting to support this for a while now, and with the recent foundational improvements this may be a bit easier to implement. Short-term solutionFor right now, one option you have is to not use the default formatter ( More robust actual solutionIdeas for a future release to further support this:
Maybe you have some ideas for how to shape those APIs yourself? Would love to hear them! |
I haven't thought a lot yet about what I think an ideal API for this would be, but I will say the idea of adding certain keys to a redaction blacklist makes me uneasy, honestly. If someone wants to actually render one of those in the error message, does that require a separate API for re-enabling those, or are you just stuck with the redaction and there's nothing you can do about it? And where is the line drawn for what makes a 'common' field that often has sensitive data? Is that going to keep expanding if people open issues about 'hey, I printed sensitive field <x> into my logs and then my system got compromised'? And adding any fields to this sort of list would be a breaking change every time. A I'd probably learn towards three additional redacting variants of |
Yep, this would be a massive downside, and I don't really like it either.
Edge cases pop up quickly once you start thinking about it. For example, should this construct even be allowed or not? Does it even make sense? either(sensitive(string), whatever) // Can you compose this thing? I don't think so. This example illustrates that object({
username: string,
password: nullable(sensitive(string)), // ❌ Not allowed
password: sensitive(nullable(string)), // ✅ Allowed
}); Another API to convey the exact same information would be to add a second config param to object(
{
username: string,
password: string,
},
{ mask: ["password"] }, // Slightly less DRY alternative, because you have to repeat the field name here
); |
I have an object I'd like to run through Decoders, and I'd like to log the errors that it throws when there are validation issues - but there's one field I'd prefer not to appear in the logs as it contains sensitive data. Is there a nice way to achieve this - or, perhaps, a nice way to have control more generally over the constructed error messages?
As a workaround, I could delete the sensitive key from the object ahead of time, run the remaining object through Decoders, and then reinstate the sensitive key afterwards, but I'm wondering whether there's some nicer way to achieve this that I'm missing. Thanks!
The text was updated successfully, but these errors were encountered: