Skip to content

Environment Secrets have no value #1264

Closed
@pjarnfelt

Description

@pjarnfelt

[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

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)
});

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions