You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normally ZodError does not contain the actual value that was invalid. IMHO this is good - errors are often logged, and there are many situations where you don't want to log the value - the value could be sensitive (credit card number, personally identifiable information, password/secret token of some kind), or it might be unsafe to log (might be several gigabytes, contain newlines, NUL bytes, ANSI terminal escape sequences, HTML, ... - some of which might cause problems when viewing logs later).
However, for z.literal and z.enum, the message does contain the input data:
> z.literal('Foo').parse('Bar')
Uncaught ZodError: [
{
"code": "invalid_type",
"expected": "Foo",
"received": "Bar",
"path": [],
"message": "Expected Foo, received Bar"
}
]
<snip>
> z.enum(['Foo','Bar']).parse('Bad')
Uncaught ZodError: [
{
"code": "invalid_enum_value",
"options": [
"Foo",
"Bar"
],
"path": [],
"message": "Invalid enum value. Expected 'Foo' | 'Bar', received 'Bad'"
}
]
<snip>
```
I would suggest aligning these two with the other errors (it looks like these are the only two exceptions), so that logged error messages can never contain the invalid input data itself.
The text was updated successfully, but these errors were encountered:
Normally
ZodError
does not contain the actual value that was invalid. IMHO this is good - errors are often logged, and there are many situations where you don't want to log the value - the value could be sensitive (credit card number, personally identifiable information, password/secret token of some kind), or it might be unsafe to log (might be several gigabytes, contain newlines, NUL bytes, ANSI terminal escape sequences, HTML, ... - some of which might cause problems when viewing logs later).However, for
z.literal
andz.enum
, the message does contain the input data:The text was updated successfully, but these errors were encountered: