Discussion about private vs public datasets and the impact of using dots in document IDs
31 replies
Last updated: May 20, 2021
J
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
H
One thing that I could think of is if the dataset is set to private.
May 20, 2021, 8:23 PM
H
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
J
It's definitely public, you can put that url in your address bar and it works
May 20, 2021, 8:26 PM
H
Nope, not for me
May 20, 2021, 8:26 PM
H
You probably have a token stored in your browser
May 20, 2021, 8:26 PM
J
oh you're right.. it doesn't work in a private window
May 20, 2021, 8:28 PM
J
didn't realise it would use your logged in session
May 20, 2021, 8:28 PM
J
but yeah..
May 20, 2021, 8:30 PM
H
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
J
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
J
and the ids do have `.`s
May 20, 2021, 8:35 PM
J
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
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.baris "private", while
foobaris 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
J
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
J
no big deal, token auth it is
May 20, 2021, 8:38 PM
J
thanks for the help!
May 20, 2021, 8:39 PM
J
no big deal, token auth it is
May 20, 2021, 8:38 PM
H
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
J
and the ids do have `.`s
May 20, 2021, 8:35 PM
J
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
J
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
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.baris "private", while
foobaris 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
J
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
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.