I am getting a weird error with firebase security rules. My current code is:
".read":
root.child('parent_to_rider').child(auth.uid).child($rider_id).exists()"
And I get the following error:
"root.child('parent_to_rider').child(auth.uid).child($rider_id).exists()"
20:57: child() expects a string argument.
=> false`
However, when I try the following code it works fine:
".read":
root.child('parent_to_rider').child('simplelogin:18').child($rider_id).exists()"
The response is:
Attempt to read /riders/-JnSvkcZ8Xs2dEnEeZdm with auth=Success(null)
"root.child('parent_to_rider').child('simplelogin:18').child($rider_id).exists()"
=> true
Read was allowed.
The security rule seems to only give error with .read, and the same rule works perfectly fine with the .write rule. I would appreciate any help here.
My complete rule block looks like this:
"riders" : {
"$rider_id" :{
//Check if mapping from rider to parent already exists
".read":
"root.child('parent_to_rider').child(auth.uid).child($rider_id).exists()",
".write":
"(root.child('parent_to_rider').child(auth.uid).child($rider_id).exists())",
}
}