Code node python unable to retrieve data after upgrade version to 2.4.4

Describe the problem/error/question

After I upgraded n8n version from 1 to version 2.4.4, my code node using python unable to retrieve data from other node (which is not the previous node) using _("<node-name>") convension.

What is the error message (if any)?

name '_' is not defined

Please share your workflow

this is full code of my code node using python, trying to retrieve data from “Validate Request” node, following this documentation It works before upgrade version.

I understand that the dot notation being changed to bracket notation I already migrate the logic. but for this issue the main thing is syntax of _("<node-name>") using python code node.

def build_volume_path(slash_command):
  from datetime import datetime

  file_name = 'raw_gg_sheet_with_gg_map'
  current_date = datetime.now().strftime('%Y-%m-%d')
  
  full_volume_path = f"{current_date}/{file_name}.csv"
  return full_volume_path

slash_cmmand = _("Validate request").item.json._slash_command ## <----- Here is where the error occur
full_volume_path = build_volume_path(slash_cmmand)

_input.item.json._volume_path = full_volume_path

return _input.item.json

Share the output returned by the last node

this is result from last node, not the node I want to retrieve

[
{
“access_token”: “token”,
“scope”: “all-apis”,
“token_type”: “Bearer”,
“expires_in”: 3600
}
]

this is result from Validate Request Node I tried to retrieve "_slash_command": "/command-slash-example-example",

[
  {
      "space": {
        "displayName": "kids-personal",
        "spaceThreadingState": "THREADED_MESSAGES",
        "spaceType": "SPACE",
        "spaceHistoryState": "HISTORY_ON",
        "lastActiveTime": "2026-01-22T08:39:56.323727Z",
      },
      "common": {
        "userLocale": "en-GB",
        "hostApp": "CHAT",
        "timeZone": {
          "id": "Asia/Bangkok",
          "offset": 25200000
        }
      },
    "executionMode": "test",
    "_slash_command": "/command-slash-example-example",
    "_command_type": "command_type",
    "_validate_pass": true
  }
]

this is the result from last node

Information on your n8n setup

  • n8n version: 2.4.4
  • Database (default: SQLite): postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): sidecar python-task-runner
  • Running n8n via (Docker, npm, n8n cloud, desktop app): AWS EC2
  • Operating system: EC2 Linux

Hi @l3looduo,

This note contains the solution:
image

Looking at your code, specifically this part:

_("Validate request") and _input aren’t supported in Python,
so depending on the mode (Run Once for Each Item / Run Once for All Items), you need to rewrite the code with the correct syntax (any AI can help with this),

Here are the working solutions for both cases:

1 Like

understand you point, actually I already have version that changed input.item to _items[0][“json”] from the mode Run once for all item .

but I am seeking resolution for retrieving data from Validate Request node, which is not from the previous node ( 4 node backs as per the picture)

1 Like

afaik and as I mentioned earlier, this is not possible because the note clearly explains this limitation, If you try to reference it anyway, you will get a name '_' is not defined error,

This is only supported in JavaScript code.

It used to work in version 1, but doesn’t work anymore.

Can I conclude this way, There is no way to retrieve data from other node that is not the previous one for v2.X.X (It used to work in version 1 by the doc I provided.)

It could possibly support in the future release OR this feature will be deprecated for code node with python.

I have 2 options for this cases, as I understand

  1. migrate logic from python to JavaScript code.
  2. redesign to workflow

Until it get supported in Python, the solution for now is simple:

Create a Set node before the Python Code node and reference all required fields from the previous nodes so they are directly available to the Python code,

Or just use the JavaScript Code node if it’s only a coding task and doesn’t require any imports..