-
-
Notifications
You must be signed in to change notification settings - Fork 37
Validation errors reported by zod are not useful #64
Comments
Is your code..minified/bundled at all? Because it definitely throws an error, as seen at the end, but a really, REALLY not helpful one |
The issue is you didn't provide a description but the description is required. |
No, i having this issue from typescript (and tsc) but i tried directly from nodejs and still throw error
Sorry, i added it. |
That's not what @Khasms meant haha. You need to call |
I known that is not he mean but really, i don't known what to write, the errore is useless. |
Hrmm, true true, the errors could be better.. I'll be reopening this but with a different title 👍 |
I updated the description to made that more consistent with title |
Hi there, one possible alternative is to wrap parsing with a custom error that unsets the stacktrace, resulting in the below: I'm willing to PR this if it seems like a good tradeoff. |
I can't reproduce the code dump at the beginning of the error, it outputs as it should on my end. But, as far as the error not being helpful, I opened #61 a week ago to improve them, so give some feedback on that if you see any other messages that need to be improved. |
@hampuskraft Not a good tradeoff since that makes parsing +2x slower, which adds up to how slow Zod's validation already is, see discordjs/discord.js#7067 (comment) |
Issue description
Calling
toJSON()
from an instance of aSlashCommandBuilder
without setting required parameters (name and description) throw an error that seem from zod that isn't useful at all to understand the problem because of the size of the error and don't say what parameter is missing.Original message:
When creating a SlashCommandBuilder and doing toJSON() zod thrown about an recived undefined and expect a string.
Step to reproduce:
SlashCommandBuilder
from@discordjs/builders
toJSON()
zodError.log
Code sample
@discordjs/builders version
0.9.0
Node.js version
node.js v17.2.0 | Typescript 4.5.4
Operating system
Windows 11
Priority this issue should have
High (immediate attention needed)
The text was updated successfully, but these errors were encountered: