Skip to content

FloatParam is not parsing env var properly #209

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

Closed
vpusher opened this issue Jun 28, 2024 · 1 comment · Fixed by #221
Closed

FloatParam is not parsing env var properly #209

vpusher opened this issue Jun 28, 2024 · 1 comment · Fixed by #221
Assignees
Labels
bug Something isn't working

Comments

@vpusher
Copy link

vpusher commented Jun 28, 2024

I have been working with Python Cloud Functions for Firebase for a few weeks now and we are having an issue when it comes to float params with FloatParam.

Basic code to reproduce:

# .env
MY_FLOAT=0.0
# main.py
from firebase_functions.params import FloatParam
import firebase_admin

firebase_admin.initialize_app()

my_float = FloatParam("MY_FLOAT").value

From that setup, I have 2 issues:

  1. The first one is that params types (string, int, boolean, float ...) cannot be read outside of a function implementation (i.e functions annotated with @tasks_fn.on_task_dispatched or @https_fn.on_call for example)
  2. Second one is, whenever I move the reading part inside of Callable/Queue function implementation, my env var value got wrapped into an array (only for float params), then I got the following error when the CF tries to start up in Cloud Run:
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/firebase_functions/params.py", line 353, in value
    return float(_os.environ[self.name])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '["0.0"]'

NB: That "array wrapping" behaviour for floats is not happening locally with emulators.

@exaby73 exaby73 added the bug Something isn't working label Jul 1, 2024
@exaby73 exaby73 self-assigned this Jul 1, 2024
@CorieW CorieW self-assigned this Nov 25, 2024
@CorieW
Copy link
Member

CorieW commented Dec 2, 2024

Hi @vpusher. It seems using a float type param isn't yet supported within firebase-tools. There is currently an issue for this in firebase-tools.

Until this feature is added, StringParam can be used and parsed.

Thanks for reporting this issue.

@CorieW CorieW closed this as completed Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants