feat(message-validator): include more details in error messages#6133
feat(message-validator): include more details in error messages#6133
Conversation
| prompt, | ||
| message: 'messages must be an array of CoreMessage or UIMessage', | ||
| message: [ | ||
| 'messages must be an array of CoreMessage or UIMessage', |
There was a problem hiding this comment.
maybe change msg to "message must be a CoreMessage or a UI message" and consider changing the InvalidPromptError so that the messages can be included and printed instead
lgrammel
left a comment
There was a problem hiding this comment.
Best practice is to include the raw information (messages, message) in the error object, vs adding to the error message itself.
Yep I was unsure on the best way to approach this problem. The issue is what if it throws it inside the stream, so it ends up being serialised as a data stream message - in that case what is the best way to surface the error message to the user. Do the errors get printed to the console terminal output automatically? If not, should we print the messages there? What about if people run into this on production, how best can we allow for this error to be fixed by the application. I imagine they'd have error reporting built into the stack somewhere, it's just a question of how we hook that up correctly (and what methods they use) I also want to make sure if we do this, that there's no possibility of leaking the system prompt as the user could malform a message. |
…el#6133) ## Background Before in issues like vercel#5499 & vercel#5833, if users ran into an issue where the messages array failed to parse correctly they'd run into a difficult to debug error `Invalid prompt: messages must be an array of CoreMessage or UIMessage` ## Summary This PR extends these error messages to include more details on what exactly went wrong, which is useful information for debugging when stuff breaks. On security: I think this is an okay change since the data sent is not private
…el#6133) Before in issues like vercel#5499 & vercel#5833, if users ran into an issue where the messages array failed to parse correctly they'd run into a difficult to debug error `Invalid prompt: messages must be an array of CoreMessage or UIMessage` This PR extends these error messages to include more details on what exactly went wrong, which is useful information for debugging when stuff breaks. On security: I think this is an okay change since the data sent is not private
Background
Before in issues like #5499 & #5833, if users ran into an issue where the messages array failed to parse correctly they'd run into a difficult to debug error
Invalid prompt: messages must be an array of CoreMessage or UIMessageSummary
This PR extends these error messages to include more details on what exactly went wrong, which is useful information for debugging when stuff breaks.
On security: I think this is an okay change since the data sent is not private
Verification
E2E tests validating new error messages
Tasks
pnpm changesetin the project root)pnpm prettier-fixin the project root)Future Work
Related Issues