Skip to content

listParam isn't loaded successfully in the emulator #1605

Open
@tzappia

Description

@tzappia

Related 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

import { beforeUserCreated } from "firebase-functions/v2/identity";
import { myList } from './params.js';

export const beforecreated = beforeUserCreated((event) => {
  console.log('My list', myList.value());
});

In params.js

export const myList = defineList('MY_LIST', { default: [] });

In env.local

MY_LIST=something,somethingElse

[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

>  {"severity":"ERROR","message":"Unhandled error SyntaxError: Unexpected token 's', \"something,somethingElse\" is not valid JSON\n    at JSON.parse (<anonymous>)\n    at ListParam.runtimeValue (/Users/tzappia/workspace/hrvst/functions/node_modules/firebase-functions/lib/params/types.js:378:26)\n    at ListParam.value (/Users/tzappia/workspace/hrvst/functions/node_modules/firebase-functions/lib/params/types.js:39:21)\n    at file:///Users/tzappia/workspace/hrvst/functions/lib/triggers/users.js:50:49\n    at wrappedHandler (/Users/tzappia/workspace/hrvst/functions/node_modules/firebase-functions/lib/v2/providers/identity.js:58:39)\n    at /Users/tzappia/workspace/hrvst/functions/node_modules/firebase-functions/lib/common/providers/identity.js:458:28\n    at /Users/tzappia/workspace/hrvst/functions/node_modules/firebase-functions/lib/common/onInit.js:33:16\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async runFunction (/Users/tzappia/.nvm/versions/node/v22.8.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:506:9)\n    at async runHTTPS (/Users/tzappia/.nvm/versions/node/v22.8.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:531:5)"}

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions