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 defineFloat() not supported in Firebase CLI #5433

Open
mattixiv opened this issue Jan 17, 2023 · 2 comments
Open

Parameters declared defineFloat() not supported in Firebase CLI #5433

mattixiv opened this issue Jan 17, 2023 · 2 comments

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 are no .env files in functions dir,
  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(randomFloat.value());
  response.send("Hello from Firebase!");
});

[REQUIRED] Steps to reproduce

Run firebase start:emulators --only functions.

[REQUIRED] Expected behavior

CLI asks user to provide value for RANDOM_FLOAT, which is then stored in an .env file.

[REQUIRED] Actual behavior

❯ firebase emulators:start --only functions --debug
[2023-01-17T14:03:47.943Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2023-01-17T14:03:47.943Z] > authorizing via signed-in user (...)
i  emulators: Starting emulators: functions {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions"}}
[2023-01-17T14:03:49.874Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
⚠  ui: Emulator UI unable to start on port 4000, starting on 4018 instead. {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI unable to start on port 4000, starting on 4018 instead."}}
[2023-01-17T14:03:49.874Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4018},{"address":"::1","family":"IPv6","port":4018}]},"metadata":{"message":"assigned listening specs for emulators"}}
[2023-01-17T14:03:49.878Z] [hub] writing locator at /var/folders/sp/hsmy0vld0xzdppy46t9xzbtm0000gn/T/hub-bug-thunderdome.json
[2023-01-17T14:03:50.183Z] [functions] Functions Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-01-17T14:03:50.183Z] [eventarc] Eventarc Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-01-17T14:03:50.183Z] late-assigned ports for functions and eventarc emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4018},{"address":"::1","family":"IPv6","port":4018}],"functions":[{"address":"127.0.0.1","family":"IPv4","port":5001}],"eventarc":[{"address":"127.0.0.1","family":"IPv4","port":9299}]},"metadata":{"message":"late-assigned ports for functions and eventarc emulators"}}
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, firestore, database, hosting, pubsub, storage {"metadata":{"emulator":{"name":"functions"},"message":"The following emulators are not running, calls to these services from the Functions emulator will affect production: \u001b[1mauth, firestore, database, hosting, pubsub, storage\u001b[22m"}}
✔  functions: Using node@16 from host. {"metadata":{"emulator":{"name":"functions"},"message":"Using node@16 from host."}}
[2023-01-17T14:03:50.186Z] defaultcredentials: writing to file /Users/matti/.config/firebase/.._application_default_credentials.json
[2023-01-17T14:03:50.191Z] Setting GAC to /Users/matti/.config/firebase/.._application_default_credentials.json {"metadata":{"emulator":{"name":"functions"},"message":"Setting GAC to /Users/matti/.config/firebase/.._application_default_credentials.json"}}
[2023-01-17T14:03:50.191Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/bug-thunderdome/adminSdkConfig [none]
[2023-01-17T14:03:50.726Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/bug-thunderdome/adminSdkConfig 200
[2023-01-17T14:03:50.726Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/bug-thunderdome/adminSdkConfig {"projectId":"bug-thunderdome","storageBucket":"bug-thunderdome.appspot.com"}
[2023-01-17T14:03:50.743Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-01-17T14:03:50.743Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2023-01-17T14:03:50.743Z] Starting Emulator UI with command {"binary":"node","args":["/Users/matti/.cache/firebase/emulators/ui-v1.11.2/server/server.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {\"binary\":\"node\",\"args\":[\"/Users/matti/.cache/firebase/emulators/ui-v1.11.2/server/server.js\"],\"optionalArgs\":[],\"joinArgs\":false}"}}
i  ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2023-01-17T14:03:50.823Z] Web / API server started at 127.0.0.1:4018
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at 127.0.0.1:4018\n"}}
[2023-01-17T14:03:50.824Z] Web / API server started at ::1:4018
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at ::1:4018\n"}}
i  functions: Watching "/Users/matti/Sources/functions-repro/functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"/Users/matti/Sources/functions-repro/functions\" for Cloud Functions..."}}
[2023-01-17T14:03:51.001Z] Validating nodejs source
[2023-01-17T14:03:51.429Z] > [functions] package.json contents: {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "index.js",
  "dependencies": {
    "firebase-admin": "^11.4.1",
    "firebase-functions": "^4.1.1"
  },
  "devDependencies": {
    "firebase-functions-test": "^3.0.0"
  },
  "private": true
}
[2023-01-17T14:03:51.429Z] Building nodejs source
[2023-01-17T14:03:51.433Z] Could not find functions.yaml. Must use http discovery
[2023-01-17T14:03:51.540Z] Serving at port 9005

[2023-01-17T14:03:51.676Z] Got response from /__/functions.yaml {"endpoints":{"helloWorld":{"platform":"gcfv1","availableMemoryMb":null,"timeoutSeconds":null,"minInstances":null,"maxInstances":null,"ingressSettings":null,"serviceAccountEmail":null,"vpc":null,"httpsTrigger":{},"entryPoint":"helloWorld"}},"specVersion":"v1alpha1","requiredAPIs":[],"params":[{"name":"RANDOM_FLOAT","type":"float"}]}
[2023-01-17T14:03:51.680Z] shutdown requested via /__/quitquitquit

⬢  functions: Failed to load function definition from source: Error: Never has a value ([object Object]). This should be impossible {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: Error: Never has a value ([object Object]). This should be impossible"}}

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://127.0.0.1:4018/               │
└─────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator  │ Host:Port      │ View in Emulator UI             │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4018/functions │
└───────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at 127.0.0.1:4400
  Other reserved ports: 4500

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
@taeold
Copy link
Contributor

taeold commented Jan 19, 2023

Hi @karvaporo - thanks for reporting the issue.

I've learned that we have not implemented the feature in the Firebase CLI to support defineFloat yet. Please keep an eye on this issue - we'll post an update here once the feature is implemented.

In the meantime, please consider using defineString and parsing it in your code:

const { defineString } = require("firebase-functions/params");

const randomFloat = defineString("RANDOM_FLOAT");

exports.helloWorld = functions.https.onRequest((request, response) => {
  functions.logger.info(Number.parseFloat(randomFloat.value()));
  response.send("Hello from Firebase!");
});

@taeold taeold changed the title Parameters declared with defineFloat() cause Error: Never has a value when starting functions emulator and project has no existing .env files Parameters declared defineFloat() not supported in Firebase CLI Jan 19, 2023
taeold added a commit to firebase/firebase-functions that referenced this issue Jan 19, 2023
Firebase CLI doesn't support defineFloat yet (firebase/firebase-tools#5433).
@JohnGale87
Copy link

Please can we have an update on this issue, it seems like a bug to me rather than a feature request. Is there an ETA for release?

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