Search code examples
firebasefirebase-tools

Can firebase functions .secret.local specify kebab case environment variable names?


Secret manager can specify kebab case secret name, but I meet the error

functions: Failed to read local secrets file /work/dist/.secret.local: Invalid dotenv file, error on lines: project-bucket-url="gs://demo-project.appspot.com"

with /work/dist/.secret.local contains

project-bucket-url="gs://demo-project.appspot.com"

though defineSecret("project-bucket-url") works with kebab case secret name in production. How can we overwrite the defined value in emulator environment?


Solution

  • Notice the error message says that file is a "dotenv" file. That has a specific format. From what I can see, hyphens are not allowed in dotenv key names.

    For the sake of portability (and sanity), environment variable names must consist solely of letters, digits, and the underscore ( _ ) and must not begin with a digit. In regex-speak, the names must match the following pattern:

    [a-zA-Z_]+[a-zA-Z0-9_]*
    

    That's probably because dotenv was invented as a method to store environment variables, which typically use underscore as a word separator, and also all caps.

    You should consider changing the names to something more conventional and supported by dotenv.