Firebase error saving rules - Line 10: String can't contain ".", "#", "$", "/", "[", or "]"

Viewed 332
2 Answers

The error you are receiving is due to some inconsistency in the documentation - The / character is disallowed. I've managed to publish a similar set of rules by changing it to nested paths.

{
  "rules": {
    "Users": {
      "$uid": { 
        ".read": true,
        ".write": "auth.uid == $uid"
      }
    }
  }
}

Note: I'm assuming you are using Firebase Realtime Database. If you are using Firestore, use request.auth.id instead

I wrote to support and they told me there was a bug in their documentation. And the correct answer is:

{
  "rules": {
    "Users" :{
      "$uid": {
        ".read": true,
        ".write": "auth.uid == $uid"
      }
    }
  }
}
Related