🗓️ Everything *[NYC] is back. A free gathering for AI builders. Sept 9

Sanity SSO broken after media plugin install: 401 Unauthorized ACL error

14 repliesLast updated: Nov 29, 2025

I have a sanity installation setup with SSO which has worked great for the last 6 months. Today i installed the media plugin (https://www.sanity.io/plugins/sanity-plugin-media ) and now things really don’t work anymore. Right after login i am greeted with an error prompt saying: “Error: Unauthorized - User must be a member of this project to perform this operation”. From the console output and network log, it looks like this error is due to a HTTP 401 response after a call to https://PROJECT_ID.api.sanity.io/v2021-06-07/projects/PROJECT_ID/datasets/DATASET_NAME/acl?tag=sanity.studio.acl.get I am running the latest version of sanity (ran sanity upgrade). Editing is completely broken and giving me an error message of: “undefined is not an object (evaluating ‘currentUser.roles.length’)“. Any suggestions on where to go from here?
AI Update

This looks like a bug that was already reported and fixed back in June 2021. Based on the discussion thread I found, here's what happened and how it was resolved:

The issue you're experiencing was caused by an incompatibility between Sanity's SSO implementation and how the Studio was handling user roles. When using SSO with third-party login tokens, the currentUser object has a role property (as a string, like "editor"), but the Studio code was expecting a roles property (as an array).

This caused the error "undefined is not an object (evaluating 'currentUser.roles.length')" in the PermissionCheckBanner component when trying to access currentUser.roles.length.

The good news: This was fixed by the Sanity team within about a day of being reported. There were actually two bugs:

Both were patched and released.

What you should do:

If you're still experiencing this issue after updating, it might be a different problem with similar symptoms. The fact that it appeared right after installing the media plugin is likely coincidental - the plugin installation probably just triggered a Studio refresh that exposed an underlying version mismatch.

If problems persist after updating, I'd recommend reaching out to Sanity's community on Discord with your current Studio version and package.json dependencies so the team can help troubleshoot further.

Show original thread
14 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