Issue with missing data in responses from the Sanity Client in Next.js 14 codebase.
Based on the symptoms you're describing and the timing ("since yesterday/today"), this is almost certainly related to the recent API version 2025-02-19 change that Sanity deployed on February 24, 2025. This is a breaking change that switched the default perspective from raw to published.
What's Happening
The intermittent missing data you're seeing (especially with media/asset references) is likely because:
- The default perspective changed to
published- Your queries are now only returning published documents by default, not drafts - Asset references might be in draft state - If the media information or asset references haven't been published (or were saved as drafts), they won't appear in the
publishedperspective - The randomness is probably due to caching - The Live CDN has a ~10 minute cache with
stale-while-revalidate, so you're seeing cached responses with the oldrawperspective mixed with fresh responses using the newpublishedperspective
Quick Fix
Update your Sanity client configuration to explicitly use the raw or previewDrafts perspective to restore the previous behavior:
import {createClient} from '@sanity/client'
const client = createClient({
projectId: 'your-project-id',
dataset: 'your-dataset',
useCdn: true,
apiVersion: '2024-01-01', // or your current version
perspective: 'raw', // Add this to get both published and draft content
})Or if you're using the Next.js integration, you can set it in your queries:
const data = await client.fetch(query, params, {
perspective: 'raw'
})Long-term Solution
You have two options:
- Keep using
perspective: 'raw'if you need both draft and published content - Ensure all content is properly published and switch to using
perspective: 'published'(the new default)
More Details
The API version 2025-02-19 changelog explains this breaking change. The default perspective switch means queries now only return published documents unless you explicitly specify otherwise. This was done to support the new Content Releases feature, but it affects all queries made without an explicit perspective parameter.
The timing of "since yesterday" aligns perfectly with this deployment, and the intermittent nature is consistent with CDN cache behavior during the transition period. You can also check status.sanity.io for any ongoing incidents, though this appears to be a planned breaking change rather than an outage.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.