Discussion about private vs public datasets and the impact of using dots in document IDs

31 replies
Last updated: May 20, 2021
Any ideas why my query is returning no results when called from a google script, but returns results otherwise?
May 20, 2021, 8:15 PM
One thing that I could think of is if the dataset is set to private.
May 20, 2021, 8:23 PM
You can change between public (everyone can read) or private (need to be authed or have token to read)
May 20, 2021, 8:25 PM
It's definitely public, you can put that url in your address bar and it works
May 20, 2021, 8:26 PM
Nope, not for me
May 20, 2021, 8:26 PM
You probably have a token stored in your browser
May 20, 2021, 8:26 PM
oh you're right.. it doesn't work in a private window
May 20, 2021, 8:28 PM
didn't realise it would use your logged in session
May 20, 2021, 8:28 PM
but yeah..
May 20, 2021, 8:30 PM
Weird, I tested to set one of my datasets to private and the kept the other public and got the same result as you describe.. unfortunately that was my only idea πŸ˜•
May 20, 2021, 8:33 PM
Are your documents published? Do the
_id
attributes contain a
.
by any chance?
May 20, 2021, 8:34 PM
not sure what it means for a document to be published.. I've only been using the data lake so far
May 20, 2021, 8:34 PM
and the ids do have `.`s
May 20, 2021, 8:35 PM
I'll have a read up on document publishing
May 20, 2021, 8:35 PM
Ah. Common gotcha - https://www.sanity.io/docs/ids
Dots are treated as "paths", and the default security rules says that anything not within the "root path" is not public to unauthenticated users
May 20, 2021, 8:36 PM
So
foo.bar
is "private", while
foobar
is public. This is the way drafts work when you use the studio: they are documents with an ID prefix:
drafts.someDocumentId
May 20, 2021, 8:36 PM
ah, I think I read that page at some point but it didn't sink in. I thought using paths in my ids was just going to give me more flexibility down the line
May 20, 2021, 8:37 PM
no big deal, token auth it is
May 20, 2021, 8:38 PM
πŸ‘
May 20, 2021, 8:38 PM
thanks for the help!
May 20, 2021, 8:39 PM
no big deal, token auth it is
May 20, 2021, 8:38 PM
πŸ‘
May 20, 2021, 8:38 PM
Weird, I tested to set one of my datasets to private and the kept the other public and got the same result as you describe.. unfortunately that was my only idea πŸ˜•
May 20, 2021, 8:33 PM
Are your documents published? Do the
_id
attributes contain a
.
by any chance?
May 20, 2021, 8:34 PM
and the ids do have `.`s
May 20, 2021, 8:35 PM
not sure what it means for a document to be published.. I've only been using the data lake so far
May 20, 2021, 8:34 PM
I'll have a read up on document publishing
May 20, 2021, 8:35 PM
Ah. Common gotcha - https://www.sanity.io/docs/ids
Dots are treated as "paths", and the default security rules says that anything not within the "root path" is not public to unauthenticated users
May 20, 2021, 8:36 PM
So
foo.bar
is "private", while
foobar
is public. This is the way drafts work when you use the studio: they are documents with an ID prefix:
drafts.someDocumentId
May 20, 2021, 8:36 PM
ah, I think I read that page at some point but it didn't sink in. I thought using paths in my ids was just going to give me more flexibility down the line
May 20, 2021, 8:37 PM
πŸ‘
May 20, 2021, 8:38 PM
Happy to help!
May 20, 2021, 8:45 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?