firebase-tools: [functions.config()] is EMPTY when running [firebase serve] or [firebase deploy] (using Node.js v10 function environment)

Related issues

I know some people have complained about this in the past but I can’t seem to get this working.

[REQUIRED] Version info

node: v10.15.0

firebase-functions: ^3.0.0

firebase-tools:

firebase: 7.3.2

firebase-admin: ^8.0.0

[REQUIRED] Test case

running firebase serve fails to read functions.config()

[REQUIRED] Steps to reproduce

I’ve tried:

  • firebase functions:config:get > .runtimeconfig.json (creates the .json file with my expected config values)
  • firebase functions:config:get | ac .runtimeconfig.json (creates the .json with NO config values, just empty .json) - so i have to manually set the file in this case
  • I’ve tried putting the .runtimeconfig.json in the functions folder
  • I’ve tried putting the .runtimeconfig.json in the src folder
  • I’ve tried putting the .runtimeconfig.json in the src & the functions folder

[REQUIRED] Expected behavior

Running firebase serve should read functions.config()

[REQUIRED] Actual behavior

functions.config() seems to always be empty

This is the location that the code should read functions.config() values

TypeError: Cannot read property ‘secret’ of undefined at Object.<anonymous> (C:\Development\stripe\functions\lib\config.js:13:49) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object.<anonymous> (C:\Development\stripe\functions\lib\source.js:5:18) at Module._compile (internal/modules/cjs/loader.js:689:30)

Were you able to successfully deploy your functions?

No… running firebase deploy --only functions gives me the exact same error. If I replace functions.config().myValue with the actual value, both firebase serve and firebase deploy work - but this isn’t the intended behavior… I don’t want my secret key value exposed in the code

image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 24 (8 by maintainers)

Most upvoted comments

Hmmm yeah I am seeing this too but interestingly I can fix it like this:

$ CLOUD_RUNTIME_CONFIG=$(pwd)/functions/.runtimeconfig.json firebase emulators:start

So I think there may be something going wrong in firebase-functions, but I will keep investigating.

In my case firebase functions:config:get | ac .runtimeconfig.json does generate a .runtimeconfig.json filled with all properties but still, the serve doesn’t load them.

This only happens in Windows 10.

Edit: looks like the first time I used firebase functions:config:get > .runtimeconfig.json and the invisible characters remained there even though I later used the ac command. Solution was to remove the file and create it again.

after few search, the issue is related here with a hack to fix 😉

https://github.com/firebase/firebase-functions/issues/264#issuecomment-398574364

I have 7.16.1 and I still have the problem on MacOS. firebase serve --only functions ----> gives undefined value in local firebase deploy --only functions ----> works in prod

Same here !

@leandro-manifesto we do not automatically download runtime configuration from prod, but you can do it yourself if you want to:

firebase functions:config:get > functions/.runtimeconfig.json

@liezl200 @LeoLetourneur if this is happening to you please open a new issue, this works in our testing so you’re likely running into something new.

Make sure you have a .runtimeconfig.json file inside your functions folder!

Are you sure you need to use the serve method and not the shell command ?