I have set the following rule in my Firestore Database rules.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function getUser(userId) {
let user = get(/databases/$(database)/documents/users/$(userId));
return user;
}
function getRole(userId) {
let roleId = getUser(userId).data.role;
let role = get(/databases/$(database)/documents/roles/$(roleId)).data; // ERROR
return role;
}
function isPermitted(entity_action, userId) {
return getRole(userId)[entity_action];
}
match /action_items/{action_item_id} {
allow get, list, read: if request.auth != null && isPermitted("action_item.read", request.auth.uid);
}
}
}
But get the following error on simulation.
Error running simulation — Error: simulator.rules line [12], column [17]. Function not found error: Name: [get].;
Error: Invalid argument provided to call. Function: [get], Argument: ["||invalid_argument||"]
Any idea how I can resolve this error that I'm getting? Attaching a screenshot of the console.



