Code node - Javascript snippet is not running anymore since worskpace update

Describe the problem/error/question

A javascript code is not running since last update. The code doesn’t look wrong on my side so I’m a bit lost.

What is the error message (if any)?

ERROR: Cannot read properties of null (reading ‘0’) [Line 10]

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.228.2 | 0.230.2
  • **Running n8n via n8n cloud

Hey @Vincent_Bonjean,

Have you tried using a code node instead of the function node to see if that works?

Looking at the code I would assume there is something missing on the input but it looks like it is there so it is a bit odd.

If you downgrade to the last version you were using does it work again?

Hi Jon, thanks for your return.

Tried to use a code node but I get the following error (not the first time since last update)

ERROR: Unknown top-level item key: index [item 0] Access the properties of an item under .json, e.g. item.json

Also tried to downgrade but I think I missed to update since a few months so the lowest isn’t working too.

Hey @Vincent_Bonjean,

That is interesting a downgrade should have resolved it if you went back to the version it was on. I wonder if maybe there is something else going on with the data.

Can you share the webhook data so we can have a play?

sure

[
  {
    "headers": {
      "host": "modjotothemoon.app.n8n.cloud",
      "x-request-id": "0fa2b4c15317bc56785f4ebd21736861",
      "x-real-ip": "10.40.29.44",
      "x-forwarded-for": "10.40.29.44",
      "x-forwarded-host": "modjotothemoon.app.n8n.cloud",
      "x-forwarded-port": "443",
      "x-forwarded-proto": "https",
      "x-forwarded-scheme": "https",
      "x-scheme": "https",
      "content-length": "5887",
      "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7",
      "content-type": "application/json",
      "user-agent": "axios/0.21.4"
    },
    "params": {},
    "query": {},
    "body": [
      {
        "json": {
          "sales_navigator_profile_url": "https://www.linkedin.com/sales/lead/ACwAAAPvqJgB3W0FTrM6b7uvWEdlkhDenY8P3dw,",
          "id": "ACwAAAPvqJgB3W0FTrM6b7uvWEdlkhDenY8P3dw",
          "full_name": "Sergio Wolfgang Engel Manchado",
          "first_name": "Sergio Wolfgang ",
          "last_name": "Engel Manchado",
          "headline": "Director de Marca y Comunicación Grupo 1844",
          "phone": null,
          "website": "www.sergioengelgroup.com",
          "twitter": null,
          "email": null,
          "description": "25 años disfrutando del Marketing en Canarias 🇮🇨 ",
          "location": "Las Palmas de Gran Canaria, Canary Islands, Spain",
          "profile_image_url": "https://media.licdn.com/dms/image/C4E03AQGhqJ3AM8X12g/profile-displayphoto-shrink_100_100/0/1618412830261?e=1687392000&v=beta&t=W2I0MmINBGk2MbpNpBV8p7CicMwb75JZi4KXG7_19PM",
          "number_connections": 7870,
          "connection_degree": 2,
          "linkedin_profile_id": "66037912",
          "linkedin_handle": "sergio-wolfgang-engel-manchado-4741481a",
          "linkedin_profile_url": "https://www.linkedin.com/in/sergio-wolfgang-engel-manchado-4741481a",
          "education": [
            {
              "school_name": "University of Wales",
              "school_url": "https://www.linkedin.com/school/university-of-wales/",
              "date": "1995 - 1999"
            }
          ],
          "school_name": "University of Wales",
          "school_url": "https://www.linkedin.com/school/university-of-wales/",
          "sales_navigator_company_url": "https://www.linkedin.com/sales/company/20483641",
          "linkedin_company_url": "https://www.linkedin.com/company/20483641",
          "job_title": "Director de Marca y Comunicación",
          "company_name": "GRUPO1844",
          "job_time_period": "0 yrs 3 mos",
          "experiences": [
            {
              "company_name": "GRUPO1844",
              "company_url": "https://www.linkedin.com/sales/company/20483641",
              "date": "2/2023",
              "description": null,
              "location": "Canarias, España",
              "title": "Director de Marca y Comunicación"
            },
            {
              "company_name": "Dinner in the Sky Germany",
              "company_url": "https://www.linkedin.com/sales/company/35599742",
              "date": "6/2021 - 3/2023",
              "description": null,
              "location": null,
              "title": "International Sales Manager"
            },
            {
              "company_name": "alegría activity",
              "company_url": "https://www.linkedin.com/sales/company/1293431",
              "date": "1/2015 - 3/2023",
              "description": "www.alegria-activity.com\nExperiential Marketing Road Show",
              "location": "Vitoria-Gasteiz y alrededores, España",
              "title": "International Account Manager"
            },
            {
              "company_name": "Sergio Engel Group/ Engelman",
              "company_url": null,
              "date": "10/2007 - 3/2023",
              "description": "Intermediación - Consultoría \nPartnerships y organización \nMayorista Textil / PPE / Otros",
              "location": "SPAIN",
              "title": "CEO/Owner"
            },
            {
              "company_name": "COPA DEL MUNDO DE BALONCESTO GRAN CANARIA 2014",
              "company_url": null,
              "date": "12/2013 - 11/2014",
              "description": null,
              "location": "GRAN CANARIA ARENA",
              "title": "Responsable de Marketing y Comercialización en FIBA Basketball WorldCup Gran Canaria 2014"
            },
            {
              "company_name": "ESCOEX International Business School",
              "company_url": null,
              "date": "3/2005 - 11/2013",
              "description": null,
              "location": "Las Palmas de Gran Canaria y alrededores, España",
              "title": "MK DIRECTOR AT ESCOEX (Fundación Bravo Murillo)"
            },
            {
              "company_name": "ESCOEX International Business School",
              "company_url": "https://www.linkedin.com/sales/company/565807",
              "date": "2010 - 2011",
              "description": null,
              "location": null,
              "title": "Co-director Master en Mk, Publicidad y Comunicación en Canarias: EM:COM ESCOEX"
            }
          ],
          "skills": [
            {
              "name": "Marketing",
              "numOfEndorsement": 28
            },
            {
              "name": "Advertising",
              "numOfEndorsement": 9
            },
            {
              "name": "Comunicaciones de marketing",
              "numOfEndorsement": 47
            },
            {
              "name": "Mercadotecnia",
              "numOfEndorsement": 56
            },
            {
              "name": "Publicidad en Internet",
              "numOfEndorsement": 33
            },
            {
              "name": "Redes sociales",
              "numOfEndorsement": 24
            },
            {
              "name": "Estrategia de mercadotecnia",
              "numOfEndorsement": 19
            },
            {
              "name": "Publicidad",
              "numOfEndorsement": 42
            },
            {
              "name": "Administración y dirección de empresas",
              "numOfEndorsement": 23
            },
            {
              "name": "Estrategia empresarial",
              "numOfEndorsement": 50
            },
            {
              "name": "Marketing en Internet",
              "numOfEndorsement": 20
            },
            {
              "name": "Business Strategy",
              "numOfEndorsement": 13
            },
            {
              "name": "Digital Marketing",
              "numOfEndorsement": 5
            },
            {
              "name": "Español",
              "numOfEndorsement": 16
            },
            {
              "name": "Inglés",
              "numOfEndorsement": 10
            },
            {
              "name": "Management",
              "numOfEndorsement": 7
            },
            {
              "name": "Marketing digital",
              "numOfEndorsement": 37
            },
            {
              "name": "Negociación",
              "numOfEndorsement": 23
            },
            {
              "name": "Public Relations",
              "numOfEndorsement": 7
            },
            {
              "name": "Planificación estratégica",
              "numOfEndorsement": 15
            },
            {
              "name": "Strategic Planning",
              "numOfEndorsement": 5
            },
            {
              "name": "Relaciones públicas",
              "numOfEndorsement": 39
            },
            {
              "name": "Marketing Communications",
              "numOfEndorsement": 9
            },
            {
              "name": "Negotiation",
              "numOfEndorsement": 5
            },
            {
              "name": "Online Marketing",
              "numOfEndorsement": 3
            },
            {
              "name": "Mercadotecnia en medios sociales",
              "numOfEndorsement": 11
            },
            {
              "name": "Dirección de marketing",
              "numOfEndorsement": 2
            },
            {
              "name": "Estrategia",
              "numOfEndorsement": 2
            },
            {
              "name": "Liderazgo de equipos",
              "numOfEndorsement": 2
            },
            {
              "name": "Plan de negocio",
              "numOfEndorsement": 2
            },
            {
              "name": "Microsoft Office",
              "numOfEndorsement": 2
            },
            {
              "name": "Investigación de mercados",
              "numOfEndorsement": 2
            },
            {
              "name": "Gestión de eventos",
              "numOfEndorsement": 2
            },
            {
              "name": "Creación y desarrollo de empresas",
              "numOfEndorsement": 1
            },
            {
              "name": "Gestión de proyectos",
              "numOfEndorsement": 1
            },
            {
              "name": "Spanish",
              "numOfEndorsement": 3
            },
            {
              "name": "Marketing Management",
              "numOfEndorsement": 2
            },
            {
              "name": "Marketing Strategy",
              "numOfEndorsement": 5
            },
            {
              "name": "Social Media Marketing",
              "numOfEndorsement": 4
            },
            {
              "name": "Business Development",
              "numOfEndorsement": 2
            },
            {
              "name": "Medios sociales",
              "numOfEndorsement": 2
            },
            {
              "name": "Online Advertising",
              "numOfEndorsement": 3
            }
          ],
          "interests": null,
          "profile_id": "66037912",
          "profile_url": "https://www.linkedin.com/in/sergio-wolfgang-engel-manchado-4741481a",
          "current_job_title": "Director de Marca y Comunicación",
          "connections": 7870,
          "company_url": "https://www.linkedin.com/sales/company/20483641",
          "current_company_url": "https://www.linkedin.com/sales/company/20483641",
          "current_company_name": "GRUPO1844",
          "current_job_time_period": "0 yrs 3 mos",
          "extracted_at": "2023-04-19T12:55:46.575000",
          "start_url": null
        },
        "pairedItem": {
          "item": 0
        }
      }
    ]
  }
]

Hey @Vincent_Bonjean,

Oddly for me that is working :thinking: or it is not returning an error anyway. It could be an issue with the Item / Items alias not working which I think was fixed in 231 but for now try the below, I have updated the function nodes to use a Code node instead.

Hi @Jon, this is very strange indeed. Just retried using your node and on the 0.230.2 version but still have the same issue popping up…

ERROR: Unknown top-level item key: index [item 0]
Access the properties of an item under `.json`, e.g. `item.json`
 Details
Error: Unknown top-level item key: index [item 0]
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Sandbox.js:99:19
    at Array.forEach (<anonymous>)
    at JavaScriptSandbox.validateTopLevelKeys (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Sandbox.js:96:27)
    at JavaScriptSandbox.validateRunCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Sandbox.js:61:26)
    at JavaScriptSandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox.js:50:21)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Code.node.js:116:25)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:652:28)

Which next steps would you advise to troubleshoot this ?

Hey @Vincent_Bonjean,

Did you try with the same test webhook data that you previously shared? Could you try with the 231 release and see if that works for you?

Retried using 231 with the same output but still have the same issue.

[
  {
    "headers": {
      "host": "modjotothemoon.app.n8n.cloud",
      "x-request-id": "0fa2b4c15317bc56785f4ebd21736861",
      "x-real-ip": "10.40.29.44",
      "x-forwarded-for": "10.40.29.44",
      "x-forwarded-host": "modjotothemoon.app.n8n.cloud",
      "x-forwarded-port": "443",
      "x-forwarded-proto": "https",
      "x-forwarded-scheme": "https",
      "x-scheme": "https",
      "content-length": "5887",
      "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7",
      "content-type": "application/json",
      "user-agent": "axios/0.21.4"
    },
    "params": {},
    "query": {},
    "body": [
      {
        "json": {
          "sales_navigator_profile_url": "https://www.linkedin.com/sales/lead/ACwAAAPvqJgB3W0FTrM6b7uvWEdlkhDenY8P3dw,",
          "id": "ACwAAAPvqJgB3W0FTrM6b7uvWEdlkhDenY8P3dw",
          "full_name": "Sergio Wolfgang Engel Manchado",
          "first_name": "Sergio Wolfgang ",
          "last_name": "Engel Manchado",
          "headline": "Director de Marca y Comunicación Grupo 1844",
          "phone": null,
          "website": "www.sergioengelgroup.com",
          "twitter": null,
          "email": null,
          "description": "25 años disfrutando del Marketing en Canarias 🇮🇨 ",
          "location": "Las Palmas de Gran Canaria, Canary Islands, Spain",
          "profile_image_url": "https://media.licdn.com/dms/image/C4E03AQGhqJ3AM8X12g/profile-displayphoto-shrink_100_100/0/1618412830261?e=1687392000&v=beta&t=W2I0MmINBGk2MbpNpBV8p7CicMwb75JZi4KXG7_19PM",
          "number_connections": 7870,
          "connection_degree": 2,
          "linkedin_profile_id": "66037912",
          "linkedin_handle": "sergio-wolfgang-engel-manchado-4741481a",
          "linkedin_profile_url": "https://www.linkedin.com/in/sergio-wolfgang-engel-manchado-4741481a",
          "education": [
            {
              "school_name": "University of Wales",
              "school_url": "https://www.linkedin.com/school/university-of-wales/",
              "date": "1995 - 1999"
            }
          ],
          "school_name": "University of Wales",
          "school_url": "https://www.linkedin.com/school/university-of-wales/",
          "sales_navigator_company_url": "https://www.linkedin.com/sales/company/20483641",
          "linkedin_company_url": "https://www.linkedin.com/company/20483641",
          "job_title": "Director de Marca y Comunicación",
          "company_name": "GRUPO1844",
          "job_time_period": "0 yrs 3 mos",
          "experiences": [
            {
              "company_name": "GRUPO1844",
              "company_url": "https://www.linkedin.com/sales/company/20483641",
              "date": "2/2023",
              "description": null,
              "location": "Canarias, España",
              "title": "Director de Marca y Comunicación"
            },
            {
              "company_name": "Dinner in the Sky Germany",
              "company_url": "https://www.linkedin.com/sales/company/35599742",
              "date": "6/2021 - 3/2023",
              "description": null,
              "location": null,
              "title": "International Sales Manager"
            },
            {
              "company_name": "alegría activity",
              "company_url": "https://www.linkedin.com/sales/company/1293431",
              "date": "1/2015 - 3/2023",
              "description": "www.alegria-activity.com\nExperiential Marketing Road Show",
              "location": "Vitoria-Gasteiz y alrededores, España",
              "title": "International Account Manager"
            },
            {
              "company_name": "Sergio Engel Group/ Engelman",
              "company_url": null,
              "date": "10/2007 - 3/2023",
              "description": "Intermediación - Consultoría \nPartnerships y organización \nMayorista Textil / PPE / Otros",
              "location": "SPAIN",
              "title": "CEO/Owner"
            },
            {
              "company_name": "COPA DEL MUNDO DE BALONCESTO GRAN CANARIA 2014",
              "company_url": null,
              "date": "12/2013 - 11/2014",
              "description": null,
              "location": "GRAN CANARIA ARENA",
              "title": "Responsable de Marketing y Comercialización en FIBA Basketball WorldCup Gran Canaria 2014"
            },
            {
              "company_name": "ESCOEX International Business School",
              "company_url": null,
              "date": "3/2005 - 11/2013",
              "description": null,
              "location": "Las Palmas de Gran Canaria y alrededores, España",
              "title": "MK DIRECTOR AT ESCOEX (Fundación Bravo Murillo)"
            },
            {
              "company_name": "ESCOEX International Business School",
              "company_url": "https://www.linkedin.com/sales/company/565807",
              "date": "2010 - 2011",
              "description": null,
              "location": null,
              "title": "Co-director Master en Mk, Publicidad y Comunicación en Canarias: EM:COM ESCOEX"
            }
          ],
          "skills": [
            {
              "name": "Marketing",
              "numOfEndorsement": 28
            },
            {
              "name": "Advertising",
              "numOfEndorsement": 9
            },
            {
              "name": "Comunicaciones de marketing",
              "numOfEndorsement": 47
            },
            {
              "name": "Mercadotecnia",
              "numOfEndorsement": 56
            },
            {
              "name": "Publicidad en Internet",
              "numOfEndorsement": 33
            },
            {
              "name": "Redes sociales",
              "numOfEndorsement": 24
            },
            {
              "name": "Estrategia de mercadotecnia",
              "numOfEndorsement": 19
            },
            {
              "name": "Publicidad",
              "numOfEndorsement": 42
            },
            {
              "name": "Administración y dirección de empresas",
              "numOfEndorsement": 23
            },
            {
              "name": "Estrategia empresarial",
              "numOfEndorsement": 50
            },
            {
              "name": "Marketing en Internet",
              "numOfEndorsement": 20
            },
            {
              "name": "Business Strategy",
              "numOfEndorsement": 13
            },
            {
              "name": "Digital Marketing",
              "numOfEndorsement": 5
            },
            {
              "name": "Español",
              "numOfEndorsement": 16
            },
            {
              "name": "Inglés",
              "numOfEndorsement": 10
            },
            {
              "name": "Management",
              "numOfEndorsement": 7
            },
            {
              "name": "Marketing digital",
              "numOfEndorsement": 37
            },
            {
              "name": "Negociación",
              "numOfEndorsement": 23
            },
            {
              "name": "Public Relations",
              "numOfEndorsement": 7
            },
            {
              "name": "Planificación estratégica",
              "numOfEndorsement": 15
            },
            {
              "name": "Strategic Planning",
              "numOfEndorsement": 5
            },
            {
              "name": "Relaciones públicas",
              "numOfEndorsement": 39
            },
            {
              "name": "Marketing Communications",
              "numOfEndorsement": 9
            },
            {
              "name": "Negotiation",
              "numOfEndorsement": 5
            },
            {
              "name": "Online Marketing",
              "numOfEndorsement": 3
            },
            {
              "name": "Mercadotecnia en medios sociales",
              "numOfEndorsement": 11
            },
            {
              "name": "Dirección de marketing",
              "numOfEndorsement": 2
            },
            {
              "name": "Estrategia",
              "numOfEndorsement": 2
            },
            {
              "name": "Liderazgo de equipos",
              "numOfEndorsement": 2
            },
            {
              "name": "Plan de negocio",
              "numOfEndorsement": 2
            },
            {
              "name": "Microsoft Office",
              "numOfEndorsement": 2
            },
            {
              "name": "Investigación de mercados",
              "numOfEndorsement": 2
            },
            {
              "name": "Gestión de eventos",
              "numOfEndorsement": 2
            },
            {
              "name": "Creación y desarrollo de empresas",
              "numOfEndorsement": 1
            },
            {
              "name": "Gestión de proyectos",
              "numOfEndorsement": 1
            },
            {
              "name": "Spanish",
              "numOfEndorsement": 3
            },
            {
              "name": "Marketing Management",
              "numOfEndorsement": 2
            },
            {
              "name": "Marketing Strategy",
              "numOfEndorsement": 5
            },
            {
              "name": "Social Media Marketing",
              "numOfEndorsement": 4
            },
            {
              "name": "Business Development",
              "numOfEndorsement": 2
            },
            {
              "name": "Medios sociales",
              "numOfEndorsement": 2
            },
            {
              "name": "Online Advertising",
              "numOfEndorsement": 3
            }
          ],
          "interests": null,
          "profile_id": "66037912",
          "profile_url": "https://www.linkedin.com/in/sergio-wolfgang-engel-manchado-4741481a",
          "current_job_title": "Director de Marca y Comunicación",
          "connections": 7870,
          "company_url": "https://www.linkedin.com/sales/company/20483641",
          "current_company_url": "https://www.linkedin.com/sales/company/20483641",
          "current_company_name": "GRUPO1844",
          "current_job_time_period": "0 yrs 3 mos",
          "extracted_at": "2023-04-19T12:55:46.575000",
          "start_url": null
        },
        "pairedItem": {
          "item": 0
        }
      }
    ]
  }
]
ERROR: Unknown top-level item key: index [item 0]
Access the properties of an item under `.json`, e.g. `item.json`

Any shots ?

If I use your example json with the workflow I posted before it is working, Have you tried pasting in the workflow I shared?

I just changed the last node in my previous attempt but duplicating yours worked indeed but it’s very odd as you just changed the last node right ?

Could be great to understand the root cause of this issue if you have any clue ?

Many thanks for your help @Jon

Hey @Vincent_Bonjean,

I changed all of the nodes :slight_smile: try using the full workflow and see if that helps.

oh I see I will dive in to see the changes. The full workflow re-works as expected. Many thanks!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.