Error: Invalid argument provided to call. Function: [get], Argument: ["||invalid_argument||"]

594 views
Skip to first unread message

Hasan Romadon

unread,
Oct 13, 2022, 12:36:05 PM10/13/22
to Firebase Google Group
Hello Guys, why this error happen?  i simulated  to create in `config/webAdmin` buat i got error and the rule not overriding

here is the code :

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
 
    match /{document=**} {
       allow read, write: if request.auth != null;
    }
     match /config/webAdmin {
          allow read;
          allow write: if userIsAdmin();
    }

    function userIsAdmin() {
        let userData = getUserData().data;
        return ("isHR" in userData) ? userData.isHR : false;
       
    }

    function getUserData() {
        let userNip = path(get(/databases/$(database)/documents/users/$(request.auth.uid)).data.nip);
      return get(/databases/$(database)/documents/$(userNip));
    }

    }
}

Screenshot_10.png

Rachel Myers

unread,
Oct 26, 2022, 3:53:30 PM10/26/22
to fireba...@googlegroups.com
Ah! That's because rules never override. If any rule grants access, as `match /{document=**} { allow read, write: if request.auth != null; }` does, access will be granted. You have to delete that line for the rest of the rules to work.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/fdf1c3b9-3e1b-4ef1-b85d-8e1921c9d532n%40googlegroups.com.

Hasan Romadon

unread,
Nov 16, 2022, 12:49:39 PM11/16/22
to Firebase Google Group
thank you for your answer.

tthen how can i make a collection except "config/webmin" is accessible only when there is auth? Do I have to create rules for each collection?

Rachel Myers

unread,
Nov 16, 2022, 4:26:28 PM11/16/22
to fireba...@googlegroups.com
Yeah, you do have to write rules for each collection, but that's recommended anyway.

Reply all
Reply to author
Forward
0 new messages