Open tzappia opened 2 months ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Hello @tzappia. Could you try wrapping the value in []
and trying again?. So MY_LIST=something,somethingElse
will become MY_LIST=[something,somethingElse]
@exaby73 that works in the emulator, but I'm not willing to try it in production (don't want to break my live deployment!) As noted in the related issues, I expect it to fail in production.
I did some testing.
For the emulator to work with defineList
the .env
file must have:
["oranges and pears", "apples"]
(with a space between list items) and ["oranges and pears","apples"]
(without a space between list items) both work the same.Like this:
EXAMPLE_LIST=["oranges and pears", "apples"]
But this style does not work in production.
It creates one list item of ["oranges and pears",
and another list item of "apples"]
which is obviously wrong. It seems to be splitting at the ,
and including the brackets and quotes and the spaces between each list item.
To make it work in production we need this in the .env
file:
EXAMPLE_LIST=oranges and pears,apples
But as the original issue has raised, this format does not work with the emulator.
Related issues
https://github.com/firebase/firebase-functions/issues/1523
[REQUIRED] Version info
node:
v22.8.0
firebase-functions:
5.1.1
firebase-tools:
13.16.0
firebase-admin:
12.4.0
[REQUIRED] Test case
In params.js
In env.local
[REQUIRED] Steps to reproduce
Run a function that uses a listParam, in this case I try to create a user so the beforeUserCreated blocking function is invoked.
[REQUIRED] Expected behavior
console log shows "My list [something, somethingElse]"
[REQUIRED] Actual behavior
Were you able to successfully deploy your functions?
I was able to successfully deploy and the listParam seems to work fine in a production environment. Is the emulator parsing the .env file differently in the emulator vs. production? Seems to be a similar behaviour in the linked bug report that was closed.