-
Notifications
You must be signed in to change notification settings - Fork 893
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
Database SDK tries to access credential even when FIREBASE_DATABASE_EMULATOR_HOST is set #3144
Comments
@filipesilva thanks for filing this! I can see the issue clearly now. The problem is that We need some way to prevent that from happening when inside the emulator. |
Oh that's interesting, I thought that the emulator somehow added credentials there. Or at any rate something similar happened in (it actually throws an error because I still had some leftover code from your firestore example but I've pushed a fix for that now :D) |
@filipesilva looks like this is actually Realtime Database specific, I wrote these two functions: const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.helloDatabase = functions.https.onRequest(async (request, response) => {
const db = admin.database();
await db.ref('/foo/bar').set({
date: new Date().toISOString()
})
response.send("Hello from Firebase!");
});
exports.helloFirestore = functions.https.onRequest(async (request, response) => {
const db = admin.firestore();
await db.doc('/foo/bar').set({
date: new Date().toISOString()
})
response.send("Hello from Firebase!");
}); I ran all three emulators. |
Very interesting, so that's why it wasn't very obvious! |
firebase-admin
in emulator without credentials
Re-assigning to @avolkovi who is on call this week, this may be something we want to transfer over to |
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
reassigning to @schmidt-sebastian since this will require changing the RTDB SDK |
@schmidt-sebastian heya, apologies for bugging you about this, but have you had time to look at it? It's still blocking us from updating the emulators since then the CI will break. |
I haven't yet. I will try to get to this this week. |
Thanks for taking the time @schmidt-sebastian. If there's anything I can do to help, or things you'd like me to test, let me know. |
Hi all, just wanted to mention that I've just tried updating and I can confirm it unblocks us, cheers! It's still possible to get an old version of RTDB while installing Clearing Thanks for all the work in getting this in! |
@filipesilva thank you for confirming that this works! |
[REQUIRED] Environment info
firebase-tools: 8.4.0
Platform: Windows
[REQUIRED] Test case
I have a test case with minimal cloud function code and emulator at https://github.com/filipesilva/firebase-emulator-credentials.
[REQUIRED] Steps to reproduce
You should see the following error log in the console:
[REQUIRED] Expected behavior
The emulated cloud function call should be successful even though there are no credentials.
[REQUIRED] Actual behavior
The emulated cloud function errors out.
Extra details:
This is a followup from @samtstern's comment on firebase/firebase-tools#1940 (comment).
It's currently not possible to use
firebase-admin
with the emulators without credentials obtained via https://cloud.google.com/docs/authentication/getting-started.This use case is especially relevant for CI, where there is no user to login and no credentials should be provided, especially on CI test runners for open-source projects that may receive PRs from forks and which to test them.
The text was updated successfully, but these errors were encountered: