-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix(ai): correctly valiate empty arrays #10093
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
Conversation
gr2m
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is worth validating with zod, or if we should update this check here (or add a new check)
ai/packages/ai/src/ui/validate-ui-messages.ts
Line 324 in 81d4308
| if (messages == null) { |
Yeah could update here also, but I thought zod is already being used for validation so it should be good. Also this null check would also be caught by zod isn't it ? I assume reason being checking this separately is to provide clear error message, which is for non empty array is provided by zod |
|
you know what let's just go ahead. If for some reason a dedicated check will be better we can change that later |
|
|
This is an automated backport of #10093 to the release-v5.0 branch --------- Co-authored-by: ANKIT VARSHNEY <132201033+AVtheking@users.noreply.github.com> Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
Background
The
validateUIMessagesandsafeValidateUIMessagesfunctions don't properly check for arrays being not-empty,Summary
Updated the zod schema to catch empty arrays passed in messages.
Manual Verification
Wrote tests with empty arrays throwing errors, this should be sufficient right ?
Checklist
pnpm changesetin the project root)Related Issues
Fixes #10003