Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Issue with running migrations and insufficient permissions error in Sanity.io

14 replies
Last updated: Dec 21, 2021
Just starting out with Sanity. I’m trying to run a migration (to update all the dates in one type of documents. When I try and run the migration with:
sanity exec migrations/myFile.js --with-user-token
I get an error:

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '../../util/requireContext'
Require stack:
- /Users/cmv/Sites/sanity/node_modules/@sanity/core/lib/actions/exec/requireContext.js
-
...
Any help? I guess I’m not 100% sure how I set up authentication correctly.
Nov 10, 2021, 5:16 PM
Thanks for raising! We're getting a fix out asap!
Nov 10, 2021, 5:17 PM
oh, so it’s not me? 😉
Nov 10, 2021, 5:23 PM
Nah, we have a bug in the latest release - sorry about that
Nov 10, 2021, 5:31 PM
We just released v2.21.11, could you try upgrading? https://github.com/sanity-io/sanity/releases/tag/v2.21.11
Nov 10, 2021, 5:54 PM
That seems to have fixed the error … thanks!
Nov 10, 2021, 5:58 PM
I get a different one now, but I suspect that’s my fault:
ClientError: the mutation(s) failed: Insufficient permissions; permission "update" required

Nov 10, 2021, 5:58 PM
Yeah that seems like you might not be logged in with a user that has enough permissions (or not for this project, at least)
Nov 10, 2021, 6:05 PM
I am the only user on this project though. 🙂 I just set it up locally and have been poking around at things. I’m not sure why I wouldn’t be able to make changes to documents via migrations (I can via Studio).
Nov 10, 2021, 6:08 PM
Hi User. If you want to DM your project ID I can take a look.
Nov 12, 2021, 12:38 AM
Hi User! Thanks, but your colleague User already helped me out yesterday. All good now!
Nov 12, 2021, 3:26 PM
Great! Thanks for letting me know, and happy to hear it.
Nov 12, 2021, 4:25 PM
Hi, I'm using sanityClient and I'm trying to make a patch and gives me the same error about the permissions for "update". I have the token for Editor role, so can't figured out what's happening.
Dec 21, 2021, 2:39 PM
1.
description: "the mutation(s) failed: Insufficient permissions; permission \"update\" required"
2. items: [{,…}]

Dec 21, 2021, 2:42 PM
description: "the mutation(s) failed: Insufficient permissions; permission \"update\" required"
items: [{,…}]
Dec 21, 2021, 2:43 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?