Upgrading Sanity and encountering an issue with the .apiversion in the schema.

8 replies
Last updated: Apr 24, 2024
Hey y’all! Just upgraded sanity and now I am seeing this in my structure. Not sure where I need to address this. Any thoughts?
AI Update

The "Structure: Node ID required" error you're seeing after upgrading Sanity is related to the Structure Builder (formerly Desk Tool). This happens because all nodes within your desk structure need an ID assigned to them.

What's happening

Normally, IDs are assigned automatically based on the title of items in your structure. However, some items require a manually assigned ID. This is especially common with document list items, where the ID refers to a specific document ID.

How to fix it

You need to explicitly set an ID by calling the .id() method in your structure configuration. Here's an example:

S.documentListItem()
  .id('website-featured-articles')  // Add this line
  .schemaType('article-set')
  .title('Site config')

Where to look

Check your structure configuration file (typically structure/index.ts or similar in your Sanity config). Look for any S.documentListItem(), S.listItem(), or similar structure builder methods that might be missing the .id() call.

If you recently upgraded from Studio v2 to v3 (or v3 to v4), this is a common issue because structure requirements became more strict. The official help article on this error has more details.

Quick tip

If you're not sure which item is causing the issue, check your browser console or terminal - it should give you more context about where in your structure the error is occurring. The error message typically points to the specific structure node that needs an ID.

user M

in the console errors or warnings it should say that
.apiversion
is required in your schema now. so I have

.apiVersion('v2024-04-01')

on all document schema views like


s.listItem()
.title(itemTitle)
.child(s
   .documentTypeList(`thing`)
   .id(`${thing?.id}`)
   .title(`item.title`)
   .apiVersion('v2024-04-01')
   .filter(........
or maybe you need to update that
apiversion
inside your schema or your api client configuration?
The first solution did the trick. Would this need to be updated after each sanity update?
I don't believe so, it came across as a breaking change.
That being said, I just update my version from an .env variable every first of the month.

I can imagine the date-based versioning easily creating a breaking change for future sanity updates that may require a feature that couldn't be backdated far enough to cover majority of user's configs. But that's also because I haven't looked into anything at all lol

definitely not something I'd do for all clients
Got it. Thanks for the help.
Hey
user M
, do you remember which version you were previously on?
I believe it was 3.30.1
Thanks!

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.

Was this answer helpful?