A big problem I am having with Firestore Rules is that using the Simulator in the Firebase Console to simulate database accesses does not correspond to the behavior I am seeing from my clients. Now I have stumbled accross an issue that I cannot seem to fix.
Issue
The following syntax works fine in the simulator:
allow create: if request.writeFields.hasAll(["a", "b", "c"]);
When requesting with the exact same fields from my Android client, I get Error performing setData, PERMISSION_DENIED: Missing or insufficient permissions.
.
The request (simplified) looks as follows:
By setting allow create;
(simplified) I have verified and identified that the problem has to be connected to request.writeFields
because my requests, only from my real clients, fail as soon as I add logic regarding that.
The simulated data access is allowed in all my tests.
My reference is the List
interface.
Question
I am wondering if I am either missing something about writeFields
(potentially connected to allow create
) and also how I am regularly seeing disparities between simulated and real accesses.
Keep in mind that my syntax works perfectly fine in the simulator, but a real request containing the exact same JSON data fails.
Recently the following error message was added to the Firebase Console Firestore Security Rules Simulator when trying to access
writeFields
:That means that it does not work in the simulator anymore, which fixes this issue.