Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stitch function updateOne errors "update not permitted"

I have a Stitch function that does a couple of things and I'm getting an error at this line:

try {
  // voteAsObjectId is the Id of the photo to vote converted to BSON.ObjectId.
  await db
    .collection('photos')
    .updateOne({ "_id": voteAsObjectId }, { "$inc": { votes: 1 }});
} catch (err) {
  throw new Error("An error occurred while updating photo's votes:" + err);
}

The error is the following:

StitchError: update not permitted

It seems like a permissions related error, but I have some other functions in my app and they successfully run every .find .insert and .aggregate queries to this collection, only the .updateOne and .updateMany operations are giving me problems.

My collection's permissions look like this:

enter image description here

This is my schema:

enter image description here

And here's a sample document:

enter image description here

like image 388
DoHn Avatar asked Sep 13 '25 20:09

DoHn


1 Answers

I would recommend checking the following:

  1. Check the Schema tab and seeing if there's anything about your documents that doesn't fit the configured schema. The schema has a default configuration that may not match the actual schema of your documents. You may need to modify this schema to get the update working.

  2. Click the edit button (the pencil) on the 'default' role, and check the "Apply When" of the role. It's possible that the document you're trying to update does not match any role, and that the role needs updating.

If that doesn't work, check the application logs by clicking the "Logs" button on the sidebar: Logs tab

There you can see the "update not permitted" error but with more details about why the update failed.

like image 188
adamchel Avatar answered Sep 15 '25 13:09

adamchel