Site build fails due to missing asset object in image parsing

6 replies
Last updated: Jun 26, 2024
Hi. I'm looking at a project for an old client where their site build fails. From what I can tell, it's because the images are not able to be parsed properly. The response JSON I see when debugging the site is missing the
asset
object.
This is what is received.

{
  file: {
    _type: 'image',
    altText: 'A cat'
  },
  _type: 'simpleImage',
  _key: '3b50e5688ba6'
}
When I inspect in their Studio, I can see the asset is present

{
        "_key": "3b50e5688ba6",
        "_type": "simpleImage",
        "file": {
          "_type": "image",
          "altText": "A cat",
          "asset": {
            "_ref": "image-319ffa6558ec64779833c8e624b0a871d2086190-5333x3000-jpg",
            "_type": "reference"
          }
        }
      }
Why might this be happening? When I last worked with them:
• They were on Sanity Studio v2 & haven't upgraded. Is this something to do with deprecation?
• They were on a free plan. Is this something that happens if they exceeded bandwidth or usage limits?
Jun 22, 2024, 1:41 PM
To clarify, their site is failing to build, not the Studio? Have I got that right?
Jun 24, 2024, 3:39 PM
user M
yes, that's right. There's a build step that checks for the file & asset property for images and that's failing as the asset property isn't present.
Jun 24, 2024, 11:12 PM
You’ll need to take a look at your frontend code and make sure you’re including the asset in your query.
Jun 25, 2024, 3:15 PM
Thanks. I made no changes to the code & it started working again.
Jun 26, 2024, 4:33 AM
Computers. 🤷‍♂️
Jun 26, 2024, 4:33 AM
Very strange!
Jun 26, 2024, 3:42 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?