Skip to content

Conversation

@samjbobb
Copy link
Contributor

@samjbobb samjbobb commented Oct 28, 2025

Background

A small percentage of the time when using the Gemini "URL Context" feature we get a Zod validation error on the response due to a missing title property.

Summary

Added .nullish() to groundingChunks[].web.title and groundingChunks[].retrievedContext.title.

Notes:

  • I've personally observed the missing title property only on groundingChunks[].web.title. I'm guessing that the same situation could occur on groundingChunks[].retrievedContext.title and they should have the same schema.
  • I used .nullish() instead of .optional() to maintain consistency with the rest of packages/google/src/google-generative-ai-language-model.ts, though I have only observed a missing (undefined) title property, not a title: null.

Open to feedback on either of those choices.

No documentation updates made. Let me know if needed.

Manual Verification

Added tests.

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)

Future Work

N/A

Related Issues

Fixes #9842

@samjbobb samjbobb force-pushed the fix/google-retrieved-context-type branch from e55db5e to 9f4d8c1 Compare October 28, 2025 22:23
@samjbobb samjbobb force-pushed the fix/google-retrieved-context-type branch from 9f4d8c1 to 01520c4 Compare October 28, 2025 22:24
@samjbobb samjbobb marked this pull request as ready for review October 28, 2025 22:24
@gr2m gr2m self-assigned this Oct 29, 2025
Copy link
Collaborator

@gr2m gr2m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great bug report and pull request, thank you Sam! Congratulations to your first contribution to the AI SDK 💐

@gr2m gr2m added the backport label Oct 29, 2025
@gr2m gr2m enabled auto-merge (squash) October 29, 2025 15:32
@gr2m gr2m merged commit c8003fb into vercel:main Oct 29, 2025
23 of 24 checks passed
vercel-ai-sdk bot pushed a commit that referenced this pull request Oct 29, 2025
…schema (#9867)

## Background

A small percentage of the time when using the Gemini "URL Context"
feature we get a Zod validation error on the response due to a missing
title property.

## Summary

Added `.nullish()` to `groundingChunks[].web.title` and
`groundingChunks[].retrievedContext.title`.

Notes:

* I've personally observed the missing `title` property only on
`groundingChunks[].web.title`. I'm guessing that the same situation
could occur on `groundingChunks[].retrievedContext.title` and they
should have the same schema.
* I used `.nullish()` instead of `.optional()` to maintain consistency
with the rest of
`packages/google/src/google-generative-ai-language-model.ts`, though I
have only observed a missing (`undefined`) `title` property, not a
`title: null`.

## Related Issues

Fixes #9842
@vercel-ai-sdk vercel-ai-sdk bot removed the backport label Oct 29, 2025
@vercel-ai-sdk
Copy link
Contributor

vercel-ai-sdk bot commented Oct 29, 2025

✅ Backport PR created: #9893

@samjbobb
Copy link
Contributor Author

@gr2m Thank you for your quick responses Gregor!

vercel-ai-sdk bot added a commit that referenced this pull request Nov 4, 2025
… metadata schema (#9893)

This is an automated backport of #9867 to the release-v5.0 branch.

Co-authored-by: Sam Bobb <[email protected]>
Co-authored-by: Gregor Martynus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect zod schema for google-generative-ai-language-model

2 participants