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

Parameters declared with defineFloat() always evaluate as 0 at runtime regardless of the value specified in .env file #5434

Closed
mattixiv opened this issue Jan 17, 2023 · 1 comment

Comments

@mattixiv
Copy link

[REQUIRED] Environment info

firebase-tools: 11.20.0

firebase-functions: 4.1.1

Platform: macOS, Debian

[REQUIRED] Test case

  1. Initialize Firebase project with functions only,
  2. update firebase-admin and firebase-functions,
  3. ensure there is functions/.env.<projectId> file with the contents RANDOM_FLOAT=0.2,
  4. replace functions/index.js contents with:
const functions = require("firebase-functions");
const { defineFloat } = require("firebase-functions/params");

const randomFloat = defineFloat("RANDOM_FLOAT");

exports.helloWorld = functions.https.onRequest((request, response) => {
  functions.logger.info(process.env);
  response.send(`Random float: ${randomFloat.value()}`);
});

[REQUIRED] Steps to reproduce

Deploy the above function.

[REQUIRED] Expected behavior

Logs should show env object with RANDOM_FLOAT:"0.2" and response should be Random float: 0.2.

[REQUIRED] Actual behavior

Logs show env object with RANDOM_FLOAT:"[\"1.0\"]" (a JSON array instead of float) and response is Random float: 0.

@taeold
Copy link
Contributor

taeold commented Jan 19, 2023

Duplicates #5433

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

No branches or pull requests

4 participants