Publishing Firestore rules: An unknown error occurred
Asked Answered
J

6

13

On a newly created project, I cannot publish any changes to the Firebase rules. Even simple changes like adding a newline to the end of the file or adding a space.

enter image description here

I feel like this may be a bug in Firestore but thought I'd ask here first...

Error saving rules –An unknown error occurred

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false; 
    }
  }
}
Jedthus answered 21/11, 2018 at 1:58 Comment(3)
If something in the console is not working the way you expect, contact Firebase support directly. firebase.google.com/support/contactGregory
Did you manage to get this issue resolved?Koval
I contacted Google support and we eventually got it working by updating the security rules using the Firebase CLI.Jedthus
E
66

I found that the Allow CORS: Access-Control-Allow-origin Chrome extension was the cause of this error for me. Disabling the extension fixed the error.

Erase answered 16/8, 2021 at 7:49 Comment(7)
Really save our timeInside
you are a saviour :)Notch
CORS helps and makes us lost time xd. ThanksUnroot
really saved my timeHyacinthhyacintha
Yes, when disabling it was allow to change rules. ThanksInside
Worked like magic. TnxLike
Yes, that was the solution for the problem 👍🏿Vergara
N
4

Install Firebase CLI in your command prompt, login in the firebase CLI, then open the .rules file with your editor(vscode, atom) and replace it with :

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

then deploy to firebase with from your command prompt with this command

firebase deploy --only firestore:rules
Nightlong answered 21/11, 2020 at 2:18 Comment(0)
H
1

Had the same issue all of a sudden, "an unknown error occurred" for the Firestore security rules. Fixed it by updating it through the Firebase CLI.

So, in the terminal do the following steps:

  1. npm install -g firebase-tools
  2. firebase login // finish the login procedure

// Set up Firestore in your project directory, creates a .rules file

  1. firebase init firestore

//Update the firestore.rules file that you can find in the root of the directory.

// Save and deploy your .rules file

  1. firebase deploy --only firestore:rules
Horatio answered 14/2, 2021 at 14:52 Comment(0)
Q
0

The only way i got it to work is through CLI, Init it, chose the existring project you have and change the rules in the .rules file, then deploy them.

Qp answered 14/8, 2021 at 16:40 Comment(0)
D
0

Simply opening Firebase storage console on incognito and changing rules then, helped for me.

Dunbarton answered 18/4, 2023 at 15:5 Comment(0)
T
0

If that doesn't work, try:

  1. Turn off all extensions in your browser.
  2. Save the rule
  3. Turn on extensions again
Trotskyism answered 3/7 at 15:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.