Skip to content

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

Closed
@mattixiv

Description

@mattixiv

[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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions