Skip to content

Conversation

@goyalshivansh2805
Copy link
Contributor

Background

When calling safeValidateUIMessages, the errors were difficult to decipher since they didn't mention what was being validated (metadata, tool, etc.). This made debugging validation issues challenging for developers using the AI SDK.

Summary

Enhanced the error messages in safeValidateUIMessages to provide better context about what's being validated:

  • Added specific context for metadata validation errors
  • Added specific context for data part validation errors
  • Added specific context for tool input/output validation errors
  • Added specific context for message structure validation errors

Each error now clearly indicates which part of the message structure failed validation and includes the message ID when applicable.

Manual Verification

I manually verified that the validation errors now include helpful context by running the tests and examining the error messages. For example, metadata validation errors now include "Metadata validation failed for message with ID [id]" in the error message.

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Related Issues

Fixes #10137 - Validation errors are difficult to read

@vercel-ai-sdk vercel-ai-sdk bot added the ai/ui label Nov 11, 2025
@goyalshivansh2805 goyalshivansh2805 changed the title Error message enhanced fix(ai): improve validation error messages with better context Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validation errors are difficult to read

1 participant