Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions cannot access Firebase Secrets, when i debug (inspect) mode #4605

Closed
if-fi opened this issue Jun 1, 2022 · 3 comments · Fixed by #5308
Closed

Functions cannot access Firebase Secrets, when i debug (inspect) mode #4605

if-fi opened this issue Jun 1, 2022 · 3 comments · Fixed by #5308
Assignees

Comments

@if-fi
Copy link

if-fi commented Jun 1, 2022

[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

  1. Add a secret: firebase functions:secrets:set TEST_API_USER
  2. Run functions emulator in debug mode: firebase emulators:start --inspect-functions --only functions
  3. 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.

@Adam-Beno
Copy link

Running into the same issue:

firebase-tools@11.8.0

Platform: Windows 10

@justinkrol
Copy link

justinkrol commented Oct 3, 2022

I'm also running into this issue.

firebase-tools@11.13.0

Platform: macOS

@taeold is this a known limitation of the --inspect-functions flag?

@Thaina
Copy link

Thaina commented Nov 15, 2022

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."}

image

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants