-
Notifications
You must be signed in to change notification settings - Fork 210
Environment Secrets have no value #1264
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
Comments
I found a few problems with this issue:
|
Thanks for reporting this @pjarnfelt! I believe a temporary workaround could be to access the underlying environment variable directly: import * as functions from "firebase-functions";
import { defineSecret } from "firebase-functions/params";
// Defined in GCloud or not, we just don't have access to its value!
const my_secret = defineSecret("my_secret");
// Remember to define runWith the secrets, (here only one in the array)
// as it should only be pupulated at runtime from GCloud
export const helloWorld = functions.runWith({secrets:[my_secret]}).https.onRequest((request, response) => {
- my_secret.value(); // Property 'value' does not exist on type 'SecretParam'.ts(2339)
+ const mySecretVal = process.env[my_secret.name];
}); @Berlioz, unlike the other param types ( String: firebase-functions/src/params/types.ts Line 364 in 5c038e6
Secret: firebase-functions/src/params/types.ts Line 338 in 5c038e6
|
The fix for this was released in |
[REQUIRED] Version info
node: v16.17.1
firebase-functions: 4.0.0
firebase-tools: 11.4.4
firebase-admin: 11.1.0
[REQUIRED] Test case
Firebase init
install latest version of admin/tools and functions. (as my versions)
import defineSecret
import { defineSecret } from "firebase-functions/params";
define functions to run with that secret
runWith({secrets:[my_secret]})
try to get the value inside the function
[REQUIRED] Steps to reproduce
now
my_secret.value();
is undefined. SecretParam (the thing defineSecret returns) only has a .name parameter, no .value()
[REQUIRED] Expected behavior
Expected to be able to reference .value() method as per the documentation
https://firebase.google.com/docs/functions/config-env
[REQUIRED] Actual behavior
cannot access the value :(
*Property 'value' does not exist on type 'SecretParam'.ts(2339)
Were you able to successfully deploy your functions?
no
The text was updated successfully, but these errors were encountered: