Emulator Suite warning about default project ID when GCLOUD_PROJECT is unset in CI tests
0 reputation · 14 Jun 2021, 08:59 UTC
0 reputation · 14 Jun 2021, 08:59 UTC
I'm setting up integration tests against the Firebase Emulator Suite (Firestore and Auth) as part of a CI pipeline. The tests never touch production, and the emulators start correctly, but the emulator logs a warning that no project ID was provided and that it is falling back to a default project ID.
My concern is determinism: some of my test helpers construct Firestore references using a hardcoded project ID, while the emulator itself may be operating under its own fallback ID when GCLOUD_PROJECT is unset. I want to understand whether this mismatch can cause subtle failures — for example, connections silently targeting a different project namespace than the one my test fixtures assume — and whether the fallback ID is stable across emulator versions and environments.
Assume a recent Emulator Suite release and the modular JavaScript SDK with connectFirestoreEmulator.
Specifically:
GCLOUD_PROJECT (or passing the project ID to initializeApp) sufficient to make the emulator and client agree on the project namespace?35275 reputation · 14 Jun 2021, 20:37 UTC
To ensure determinism and eliminate the warning, you must explicitly synchronize the project ID between your environment and your client initialization. Setting the GCLOUD_PROJECT environment variable in your CI pipeline is the most effective way to align the Emulator Suite and the JavaScript SDK.
GCLOUD_PROJECT=your-test-project-id.const app = initializeApp({
projectId: 'your-test-project-id',
// other config
});
connectFirestoreEmulator(db, '127.0.0.1', 8080) as usual.When GCLOUD_PROJECT is unset, the emulator typically falls back to a hardcoded ID (often demo- prefixed or default). While this has remained stable across recent versions, relying on it is a risk. If a future update changes the fallback string, any test helpers using a hardcoded project ID will suddenly target a different namespace, causing tests to fail.
A project ID mismatch between the client and the emulator does not typically trigger a connection error. Instead, the emulator treats the request as belonging to a separate project namespace. This leads to "silent" failures where:
null instead of the expected fixtures.To verify your fix, check the following:
WARNING: Emulator Firestore: No project ID provided message.Diagnostic Detail Needed: Are you using the --project flag in your firebase emulators:start command? If so, that flag overrides GCLOUD_PROJECT and must be updated to match your SDK config.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.