node-red / node-red

Low-code programming for event-driven applications
http://nodered.org
Apache License 2.0
18.93k stars 3.31k forks source link

Group JSON Environment Variables can't be read #4751

Closed 3DVN closed 2 weeks ago

3DVN commented 2 weeks ago

Current Behavior

When trying to retrieve data stored as a JSON object in a group environment variable, the "ReferenceError: clone is not defined" error is thrown in the debug window. However, when trying to retrieve the same JSON object from a flow environment variable, it is returned as expected.

Test Screenshot

Group Variable

Flow Variable

This is being observed in multiple deployments using v3.1.9, and I believe the same thing is happening for the J: expression variable type.

Expected Behavior

Since data can be stored in the JSON format, it should be able to be read as such.

Steps To Reproduce

Create two JSON environment variables - one at a group level and one at a flow level. Try referencing those variables in a flow. Example attached.

Example flow

[
    {
        "id": "637ca52003cd8ddf",
        "type": "tab",
        "label": "Group Variables Issue",
        "disabled": false,
        "info": "",
        "env": [
            {
                "name": "flowFields",
                "value": "{\"test\":true}",
                "type": "json"
            }
        ]
    },
    {
        "id": "c2945ba4f9673b05",
        "type": "group",
        "z": "637ca52003cd8ddf",
        "name": "",
        "style": {
            "label": true
        },
        "nodes": [
            "177ad60a4d4db219",
            "d71bec5b3195430e",
            "e8d6b24399ad8e96",
            "6c8f40c5dc7fe1ed"
        ],
        "env": [
            {
                "name": "groupFields",
                "value": "{\"test\":true}",
                "type": "json"
            }
        ],
        "x": 814,
        "y": 239,
        "w": 512,
        "h": 122
    },
    {
        "id": "177ad60a4d4db219",
        "type": "inject",
        "z": "637ca52003cd8ddf",
        "g": "c2945ba4f9673b05",
        "name": "Group JSON Variable",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "groupFields",
        "payloadType": "env",
        "x": 960,
        "y": 280,
        "wires": [
            [
                "d71bec5b3195430e"
            ]
        ]
    },
    {
        "id": "d71bec5b3195430e",
        "type": "debug",
        "z": "637ca52003cd8ddf",
        "g": "c2945ba4f9673b05",
        "name": "group test output",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1190,
        "y": 280,
        "wires": []
    },
    {
        "id": "e8d6b24399ad8e96",
        "type": "inject",
        "z": "637ca52003cd8ddf",
        "g": "c2945ba4f9673b05",
        "name": "Flow JSON Variable",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "flowFields",
        "payloadType": "env",
        "x": 950,
        "y": 320,
        "wires": [
            [
                "6c8f40c5dc7fe1ed"
            ]
        ]
    },
    {
        "id": "6c8f40c5dc7fe1ed",
        "type": "debug",
        "z": "637ca52003cd8ddf",
        "g": "c2945ba4f9673b05",
        "name": "flow test output",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1180,
        "y": 320,
        "wires": []
    }
]

Environment

knolleary commented 2 weeks ago

Confirmed - can see the issue. Will get a 3.1.10 release sorted in the next couple days.