
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis 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:
roles vs role property mismatch (causing the "currentUser.roles.length" error)/acl endpoint due to system groups having an unexpected shapeBoth were patched and released.
What you should do:
Update your Sanity packages - Run npm update or yarn upgrade to ensure you have the latest versions, particularly @sanity/desk-tool (or @sanity/structure in Studio v3+)
Clear your node_modules and reinstall - Sometimes a clean install helps:
rm -rf node_modules package-lock.json
npm installCheck your Studio version - If you're still on Studio v2, consider upgrading to Studio v3 (now v4 is available), as these older bugs are definitely resolved in newer versions. Run sanity upgrade to get the latest versions.
Verify your SSO token generation - Make sure your SSO implementation is following the current third-party login documentation and that your tokens are being generated correctly.
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.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store