Delete Trigger with document preimage error

Hello!,
I have a trigger set to run when a player document is deleted. The purpose is so that I can also remove a file (a profile image) from a cloud server when the player is deleted. However, the link to that file is stored in the player document so I need access to it during the delete function.

After some research, I tried to enable Document Preimage in the delete trigger but I get this error:

sync incompatible role change not allowed: service contains a sync incompatible role “readOwnWriteOwn” that was previously compatible

The rules for that collection are fairly simple:


    "roles": [
        {
            "name": "readOwnWriteOwn",
            "apply_when": {},
            "document_filters": {
                "read": {
                    "owner_id": {
                        "%stringToOid": "%%user.id"
                    }
                },
                "write": {
                    "owner_id": {
                        "%stringToOid": "%%user.id"
                    }
                }
            },
            "insert": true,
            "delete": true,
            "search": true,
            "read": true,
            "write": true
        }

Note that “owner_id” is a queryable field and all device sync stuff works fine with all of my collections. That is, until I try to change the delete trigger to include a document preimage. I’ve scoured a lot of the docs and I’m just not seeing why that change is not sync compatible.

Thanks for any tips!

Hi, that sounds very stange. I would not expect anything with triggers to affect the sync compatibility of rules. Are you sure there is nothing else in the draft you are trying to deploy?

Can you send a link to your application in the service.cloud.mongodb.com (you can send this to me as a DM on the forums)

Best
Tyler

Message sent, thanks!

Have you made any progress with this issue since @Shane_Bridges? I am dealing with the same problem :frowning_face:

As it stands, the only option is to redesign the database to not rely on functions that use the document preimage.

Hi Gavin,
No, I didn’t. I had to create a new App services project and recreate all the functions. It works fine now. I still have the old project there in case the MongoDb folks want to troubleshoot the problem.

1 Like

Hi, we are still tracking this work and creating an internal ticket for it. We will follow up if we find anything that would explain this behaviour but we have been unable to reproduce it and haven’t had any more reports of this. That being said, we will continue looking into this.

Best,
Tyler

1 Like