-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
[REQUIRED] Environment info
firebase-tools: 12.0.0
Platform: macOS
[REQUIRED] Test case
No test case, but the behavior is defined here:
firebase-tools/src/functions/env.ts
Lines 163 to 180 in 56fb8a3
| export function validateKey(key: string): void { | |
| if (RESERVED_KEYS.includes(key)) { | |
| throw new KeyValidationError(key, `Key ${key} is reserved for internal use.`); | |
| } | |
| if (!/^[A-Z_][A-Z0-9_]*$/.test(key)) { | |
| throw new KeyValidationError( | |
| key, | |
| `Key ${key} must start with an uppercase ASCII letter or underscore` + | |
| ", and then consist of uppercase ASCII letters, digits, and underscores." | |
| ); | |
| } | |
| if (RESERVED_PREFIXES.some((prefix) => key.startsWith(prefix))) { | |
| throw new KeyValidationError( | |
| key, | |
| `Key ${key} starts with a reserved prefix (${RESERVED_PREFIXES.join(" ")})` | |
| ); | |
| } | |
| } |
Edit: And I wrote a possible fix in the next comment below this one.
[REQUIRED] Steps to reproduce
Create a project using the Functions emulator, create a .env file with a reserved env var like FIREBASE_PROJECT_ID and run firebase emulators:start.
[REQUIRED] Expected behavior
It should log a warning but still be able to run the emulator. Other tools in the project may depend on that env var, it's only disallowed for Firebase, so crashing creates a compatibility issue with basically all other tools that need to access Firebase.
[REQUIRED] Actual behavior
It crashes the emulator with the following error:
Failed to load function definition from source: FirebaseError: Failed to load environment variables from .env.