firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.61k stars 3.95k forks source link

🐛 [rtdb, firestore, storage] permission denied errors are unhelpful #11677

Closed lukepighetti closed 2 weeks ago

lukepighetti commented 11 months ago

Whenever we get a permission denied error (due to Rules), they are unhelpful. The expectation is to see the path and operation that failed, and optionally the JSON payload that was sent

How it works today

RTDB:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_database/permission-denied] 
Client doesn't have permission to access the desired data.

Firestore

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: [cloud_firestore/permission-denied] 
The caller does not have permission to execute the specified operation.

Cloud Storage

FLTFirebaseStorage: An unknown error occurred while calling method Reference#getDownloadURL

Ideal outcome

RTDB:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_database/permission-denied] 
Client doesn't have permission to read /foo/bar/baz.

Firestore

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: [cloud_firestore/permission-denied] 
The caller does not have permission to write /foo/bar/baz with payload {"hello": "world"}

Cloud Storage

FLTFirebaseStorage: An unknown error occurred while calling method Reference#getDownloadURL 
for "gs://foo.appspot.com/foo/bar/baz.jpg"

Resources

Firestore codepaths seem to have enough context to give better error messages without a big lift

Screenshot 2023-10-06 at 9 47 08 AM
gOzaru commented 10 months ago

I also have this error. I used to be able to retrieve data correctly without any error. But now, it denies all my request to ask data from Firestore in latest updated of cloud_firestore. I wonder what happened.

gOzaru commented 10 months ago

Okay, now it is fixed. Thank you team

cbenhagen commented 2 weeks ago

@Lyokone I can't seem to find the commits that improved the error messages. Has this really happened or was this issue closed because of the seemingly unrelated comments above?