Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does firebase simulator throw a invalid agument error when i test for update or create?

This is my error: Error running simulation — Error: simulator.rules line [10], column [13]. Function not found error: Name: [get].; Error: Invalid argument provided to call. Function: [get], Argument: ["||invalid_argument||"]

When i run this i have used all the resources i can find on the web and found nothing that will work (the allow read works and create does when i just use isSignedIn() ) ... little help please.

service cloud.firestore {
	match /databases/{database}/documents{
    match /users/{documents} {     
	 function isSignedIn() {
         return request.auth != null;
    }
	 function getRole(admin){
   		return get(/databases/$(database)/documents/users.[request.auth.uid]).data.admin;   		
   }        
     allow read: if true; 
     allow write: if getRole(admin) == true;    
    }
  }  
}

Here is my db

like image 996
David Tomlinson Avatar asked Oct 19 '18 19:10

David Tomlinson


1 Answers

You need to check that user authentificated before trying to get role of user in getRole function. Exception occurs because request.auth.uid is null. Also check that users.[request.auth.uid] is valid path.

like image 70
WhoKnows Avatar answered Sep 18 '22 07:09

WhoKnows