-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permission denied on set value #16
Comments
When you authenticate with the Admin SDK, you should have full read and write access. The |
hi @jwngr yes I use the standard |
'read' is working fine for me, as in this code:
|
apparently my database trigger function also failed with permission denied error, got this error on the log
my code:
|
Hey @azraelx23, I'm starting to get lost in all the different directions this is heading. Let me give you some general tips about how things are supposed to work and then maybe you can help put together a clear repro of the issue for me. The In your initial post, you are using In order for me to help you, I'll need to see an mcve of your problem. This would include the full contents of you Hope that helps. |
Sorry @jwngr, but let's focus on the last code which is the database trigger because I think the issue is related. The first post was using HTTP trigger, so I cannot access the adminRef through the event object. However, on my last post, it is using database trigger and I changed it to this per your suggestion:
However, it still throws out the permission denied error. |
Ahh okay, now all the different posts are starting to make more sense. Thanks for clarifying. I am really surprised that the latest code you shared doesn't work and throws a permission denied error. I honestly don't have a suggestion for you at the moment, other than to double check that the deploy actually was successful and the permission denied is coming from the correct Cloud Function. Can you also copy the full error log statement you see in your Functions Console? Other things I can think of are getting rid of all other Functions and even the It also though has been a long day around here and it's getting late, so I may just be losing my touch 😪 I'll sleep on this and hopefully some of my suggestions above can help you debug this further. |
hi @jwngr appreciate that you are still replying late at night, I completely understand 👍 I have updated my index.js to the very barebones, I also include my package.json
package.json:
The error log that I got: Thanks! |
FYI, I also tried deleting the admin.initializeApp() call, but still no dice, same error. |
The error log is for a transaction at /gathering/livestream-galih-samudra/count |
@ahaverty sorry please ignore the very first post and check my latest sample code, it is a database trigger and it has transaction right on this line
|
This behavior seems very unusual. And the fact that this same code works in a different projects makes me think something is just messed up with this particular project. One thing I would suggest trying is to disable and re-enable the Cloud Functions API entirely and see if that resets things. To do that, you need to follow these steps:
Give that a shot and let me know if it solves this problem. |
Hi @jwngr , some updates, I did the first step that you outlined , however I noticed that there was 1 function remaining there even though I deployed an empty index.js, looks like my coworker deployed a function from his machine before I deployed my functions. Perhaps it's the source of this whole fiasco? I am trying to contact him first to try having him delete his function before restarting the API. |
@jwngr my coworked deleted his function, and I was able to disable and re-enable the functions API, after that I proceeded to upload the non-empty index.js , however I still got the same permission denied error. |
Wow, this one is really quite a doozy... I think I'm going to have to hand you off to some other people on the team who can help you debug this. Can you please send me an email at <MY_GITHUB_USERNAME>@google.com and include the project ID of both of your projects, indicating which one the code succeeds for an which one the code fails for. Also, if you don't mind, sending me the full |
@jwngr just sent you that email, thanks for everything! |
Mystery solved! After a bunch of back and forth, we finally tracked down the underlying problem. Cloud Functions use your Firebase project's App Engine default service account to authenticate Thanks to @azraelx23 for helping to debug this and being patient while we tracked it down! |
Thanks @jwngr and firebase team! Great team effort! |
Hi @jwngr , we have a similar project that uses transactions and updates. However we checked the App Engine default service account and it was already editor, however we are getting the exact same error? I know this is an old post but there have been quite a few changes/updates to firebase over the last week or so and we're wondering if the problem lies on our side or the firebase side? Hoping this doesn't go unseen - Thanks |
Hi @mthompson9, have no fear, we've seen your comment! Since the above solution didn't solve your problem, it sounds like there must be another cause, so could you please go ahead and open a new Issue? In the Issue it would be helpful to see some code snippets and/or as concise of a repro as possible. Thanks! |
In my case, my default service agent was unable to make edits to the Firestore until I added the "Firestore Service Agent" role to it. |
I am simply doing this:
admin.database().ref(
/chat/last_message/${currentUserId}).set(currentTimestamp);
however I get:
FIREBASE WARNING: set at /chat/last_message/46wyOyreyYSocywqEt1g3943OAH2 failed: permission_denied
even though my database rule is only:
Strange thing is I do the exact thing on my other firebase account, and it worked perfectly fine.
The text was updated successfully, but these errors were encountered: