Joint session with Vercel: How to build intelligent storefronts (May 15th)

Reference search fails: "Attribute name cannot be an empty string" error

32 repliesLast updated: Nov 30, 2025

⚠️ Sanity Team, I'm in a really weird spot where my reference fields are failing with the following error message:
Reference search failed
Attribute name cannot be an empty string
Upon inspection, it looks like I'm running into a schema issue or something. This error only seems to appear with specific doc types. I've narrowed it down to specific doc types, but I can't tell where the error is stemming from.

It looks like my studio query is setting an attribute name to
@[""]
which can be seen in this XHR request in Chrome developer tools:
<https://x6q9abew.api.sanity.io/v2021-03-25/data/query/development?query=*[_type> in $__types&amp;&amp;!(_id in path('drafts.**'))][0...$__limit]{_type == "pageArchive" =&gt; { "w0": _id,"w1": _type,"w2": title,"w3": @[""],"w4": slug.current,"w5": message,"w6": seo.seoTitle,"w7": seo.seoDescription },}&amp;$__types=["pageArchive"]&amp;$__limit=1000&amp;tag=sanity.studio.search.reference
Note:
"w3": @[""]

Of course, this is coming at a time when we're trying to launch a site.

Anyone able to shed some light on this?
AI Update

This is a classic preview configuration issue in Sanity! The error "Attribute name cannot be an empty string" with @[""] in your GROQ query happens when your schema has a preview select configuration that's trying to access a field with an empty string as the key name.

Looking at your XHR request, the generated query shows "w3": @[""], which means Sanity is trying to select a field with an empty name. This is almost always caused by a misconfigured preview.select in your schema definition.

Here's what's likely happening:

In your pageArchive document type (or one of the types it references), you probably have something like this in your preview configuration:

preview: {
  select: {
    title: 'title',
    subtitle: 'slug.current',
    '': 'someField',  // ← This empty string key is the problem!
    // or
    media: ''  // ← Or an empty string value
  }
}

How to fix it:

Quick debugging tip: Search your schema files for patterns like:

Once you remove or fix the empty string attribute name in your preview configuration, restart your Studio and the reference search should work properly. Since you're in a launch situation, this should be a quick fix once you locate the offending schema definition!

Show original thread
32 replies

Was this answer helpful?

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.

Related contributions