Functions cannot access Firebase Secrets, when i debug (inspect) mode
[REQUIRED] Environment info
firebase-tools:11.0.1
Platform:MacOS
[REQUIRED] Test case
export const testSecretAccess = functions
.region("europe-west3")
.runWith({
secrets: ["TEST_API_USER"],
})
.https.onRequest(async (request, response) => {
functions.logger.info(`SECRET: ${process.env.TEST_API_USER}`);
response.send({
status: process.env.TEST_API_USER ? "success" : "failed",
});
});
[REQUIRED] Steps to reproduce
- Add a secret:
firebase functions:secrets:set TEST_API_USER - Run functions emulator in debug mode:
firebase emulators:start --inspect-functions --only functions - Trugger the function
http://localhost:5001/<PROJECT_NAME>/europe-west3/testSecretAccess
[REQUIRED] Expected behavior
The value of the secret is logged, and "success" is returned as a response.
Log:
> {"severity":"INFO","message":"SECRET: test"}
Response:
{"status":"success"}
[REQUIRED] Actual behavior
Log:
> {"severity":"INFO","message":"SECRET: undefined"}
Response:
{"status":"failed"}
NB: The expected result is achieved, when we run the emulator without debug mode: firebase emulators:start --only functions. The probelm appears only in debug mode.
I'm also running into this issue.
[email protected]
Platform: macOS
@taeold is this a known limitation of the --inspect-functions flag?
I still got this warning in 11.16.0 when run in firebase emulator with --inspect-functions
{"severity":"WARNING","message":"No value found for secret parameter "DIALOGFLOW_KEYFILE". A function can only access a secret if you include the secret in the function's dependency array."}
{"severity":"WARNING","message":"No value found for secret parameter "FACEBOOK_TOKENS". A function can only access a secret if you include the secret in the function's dependency array."}

This is my code
const functionsParams = require('firebase-functions/params');
var FACEBOOK_TOKENS = functionsParams.defineSecret("FACEBOOK_TOKENS");
var DIALOGFLOW_KEYFILE = functionsParams.defineSecret("DIALOGFLOW_KEYFILE");
exports.WebHook = functions.region("asia-east1").runWith({ secrets: [FACEBOOK_TOKENS,DIALOGFLOW_KEYFILE] }).https.onRequest(async (request,response) => {
console.log(DIALOGFLOW_KEYFILE.value());
console.log(FACEBOOK_TOKENS.value());
It also have weird behaviour that 1 in 10 times it might get the value for unknown reason