When subworkflows are called, they cannot access $vars object and use n8n Variables?

Describe the problem/error/question

I just upgraded to Business and now have access to variables. I’m trying a very simple use of them and finding that a subworkflow, when called, cannot resolve the $vars object. But if I just manually call the subworkflow to test it, it works. Please tell me this is a bug :roll_eyes:

What is the error message (if any)?

Please share your workflow

This is the calling WF

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "31efa39a-cbf7-439a-9bab-2f2b3bc0e246",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "2DP3kuVYs2iEBwP8",
          "mode": "list",
          "cachedResultUrl": "/workflow/2DP3kuVYs2iEBwP8",
          "cachedResultName": "Agent Workflows — SubWF"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {}
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.3,
      "position": [
        208,
        0
      ],
      "id": "8a9ced2f-f518-4d24-94b0-c6f2c4c6a28b",
      "name": "Call 'SubWF'"
    }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Call 'SubWF'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "instanceId": "f35a2873842c236fe446a77d860bb0c2fdae7f09a67dd0b280ad5680de01fafc"
  }
}


This is the subWF getting called.

{
“nodes”: [
{
“parameters”: {
“inputSource”: “passthrough”
},
“type”: “n8n-nodes-base.executeWorkflowTrigger”,
“typeVersion”: 1.1,
“position”: [
0,
0
],
“id”: “2b88243e-6e3a-4e0b-912a-a6a11ce2e477”,
“name”: “When Executed by Another Workflow”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “a7e9ac8c-7904-4c53-ae65-1a67a43920f2”,
“name”: “MyValue”,
“value”: “={{ $vars.SomeVariable }}”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
208,
0
],
“id”: “ba1ae72e-a842-4404-9ea8-694110e72e0c”,
“name”: “Edit Fields”
}
],
“connections”: {
“When Executed by Another Workflow”: {
“main”: [
[
{
“node”: “Edit Fields”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“instanceId”: “f35a2873842c236fe446a77d860bb0c2fdae7f09a67dd0b280ad5680de01fafc”
}
}

Share the output returned by the last node

When I run this from the parent WF, my output is null in the subWF. If I run the subWF directly, I get my variable value.

Information on your n8n setup

  • n8n version: 1.121.2
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Queue
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

Thanks! 1.121.3 fixed it for me. Whew! That was a little scary. Pretty important feature to get working.

1 Like