Unexpected "Prismic ref needs an access token" errors

During some builds today and also a few weeks ago, I saw some errors saying "Prismic ref needs an access token". But I'm querying only for data from the tip of "master", and I have "public API for master only" configured, so it should be public, and I'm surprised to get that error.

I wonder if what might be happening is that some document is published during the course of the build. This might mean that the ref I'm querying for is no longer the latest, and so is no longer public.

Is this the most likely explanation?

If so, I can just add an access token to this build task and move on. But if not, there might be a bug lurking somewhere.

Hey @bart ,

Thanks for flagging this error. I'm not familiar with it. Can you tell me more about what causes it? And could you share a copy-paste and screenshot of the error where it appears?

Thanks,
Sam

We'll I'm not entirely sure -- I'm asking you what causes it!

I don't have the exact error message since I restarted the builds which failed and they then passed. It seems Travis doesn't hold on to the old build output if you restart a build. I'll make sure to capture it if I see it again.

However, I got the errors in response to GraphQL queries. They were 4xx errors (likely "forbidden"), and the error message said that I needed an access token to query that particular Prismic ref.

As I said above I think it's quite likely it's because something was published mid-build, and my code is still using what was the "master" ref when the build started in successive queries, but this is no longer public.

I'm asking whether you agree that this is a likely explanation.

Hey @bart,

That helps, thanks. I'll check with the dev team to see if that could be a possible explanation, or if they can think of anything else.

Just so you know, I'll be out on Monday and Tuesday, so I probably won't get to respond until Wednesday.

Best,
Sam

Hey @bart ,

The dev team confirmed that, yes, your explanation is totally plausible. Let me know if you need anything else!

Sam

1 Like

This issue has been closed as it has been fixed, Flag if it is not the case for you to reopen.