agentsclimarketplace

N8n errors expressions

Skill Impertio-Studio/n8n-Claude-Skill-Package/skills/source/n8n-errors/n8n-errors-expressions

21 deterministic Claude AI skills for n8n v1.x workflow automation

Install
npx -y skills add Impertio-Studio/n8n-Claude-Skill-Package --skill n8n-errors-expressions

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use when debugging expression evaluation failures or undefined references in n8n workflows. Prevents data access errors by mapping every expression variable to its valid context. Covers undefined $json references, type mismatches, missing paired items, $itemIndex unavailability in Code node, $secrets restriction in Code node, JMESPath parameter order confusion, empty expression results, and context-dependent variable availability. Keywords: n8n, expression, error, $json, variable, type mismatch, expression error, undefined value, variable not found, wrong type, empty result..

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

10.9 KB, as published. Nobody here has run it

n8n Expression Error Diagnosis

Diagnose and fix expression evaluation failures in n8n v1.x workflows. For error type details see references/methods.md. For before/after fixes see references/examples.md. For anti-patterns see references/anti-patterns.md.


Quick Diagnostic Table

SymptomCauseFix
undefined when accessing $json.fieldField does not exist on current itemCheck field name spelling; use $json?.field or $ifEmpty($json.field, fallback)
TypeError: Cannot read properties of undefinedAccessing nested field on null/undefined parentChain optional access: $json.parent?.child?.value
$itemIndex is not defined in Code node$itemIndex is NOT available in Code nodeUse items.indexOf(item) or loop index variable instead
$secrets is not defined in Code node$secrets is NOT available in Code nodeUse $env.SECRET_NAME or pass secret via preceding Set node
$response is not defined$response used outside HTTP Request nodeONLY use $response in HTTP Request node parameter fields
Paired item not foundItem linking broken between nodesUse $("<Node>").first() or $("<Node>").all()[index] instead of .item
JMESPath returns unexpected resultParameter order swappedALWAYS use $jmespath(object, searchString) — object first, search second
Expression returns empty stringField exists but value is null, "", or undefinedUse $ifEmpty($json.field, "default") to provide fallback
$getWorkflowStaticData returns emptyStatic data not available during manual testALWAYS test static data with active workflow (webhook/trigger), NEVER manual execution
TypeError: X is not a functionCalling n8n extension method on wrong typeVerify data type: .extractEmail() requires string, .average() requires array
$("<Node>").item returns wrong dataExpression evaluated in non-matching contextUse $("<Node>").itemMatching(index) in Code node; use .first() or .all() for explicit access
Python AttributeError on item accessUsing dot notation in Python Code nodeALWAYS use bracket notation: item["json"]["field"]
$pageCount is not definedUsed outside HTTP Request node pagination$pageCount is ONLY available in HTTP Request node
Number treated as string in comparisonn8n expression returned string typeExplicitly convert: Number($json.price) or use parseInt()/parseFloat()
Date comparison failsComparing string dates instead of DateTimeConvert with .toDateTime() then compare with .diffTo() or .isBetween()

Variable Availability Matrix

Use this matrix to determine which variables are available in each context.

VariableExpression FieldsCode Node (JS)Code Node (Python)HTTP Request Node
$json / $binaryYESYES_json / _binaryYES
$input.itemYESYES (each-item mode)_itemYES
$input.all()YESYES_itemsYES
$("<Node>").itemYESNO (use .itemMatching())NOYES
$("<Node>").itemMatching()YESYESYES (_("<Node>"))YES
$itemIndexYESNONOYES
$runIndexYESYESYESYES
$secretsYESNONOYES
$envYESYES_envYES
$varsYESYES_varsYES
$now / $todayYESYESYESYES
$executionYESYES_executionYES
$workflowYESYES_workflowYES
$prevNodeYESYESYESYES
$responseNONONOYES
$pageCountNONONOYES
$parameterYESYESYESYES
$ifEmpty()YESYESYESYES
$jmespath()YESYES_jmespath()YES
$getWorkflowStaticData()YESYES_getWorkflowStaticData()YES
$execution.customDataYESYES_executionYES

Decision Tree: Expression Not Working

Expression returns unexpected result
|
+-- Is the variable available in this context?
|   +-- NO --> Check Variable Availability Matrix above
|   +-- YES --> Continue
|
+-- Does the field exist on the item?
|   +-- Check with: {{ Object.keys($json) }}
|   +-- Field missing --> Fix field name or check upstream node output
|   +-- Field exists --> Continue
|
+-- Is the value null/undefined/empty?
|   +-- YES --> Use $ifEmpty($json.field, fallback)
|   +-- NO --> Continue
|
+-- Is the type correct?
|   +-- String where number expected --> Number($json.field)
|   +-- Number where string expected --> String($json.field)
|   +-- String where date expected --> $json.field.toDateTime()
|   +-- Type is correct --> Continue
|
+-- Is item linking the problem?
|   +-- "Paired item not found" error --> See Paired Item Errors below
|   +-- Wrong item data --> Use explicit .first()/.all() instead of .item
|   +-- Correct linking --> Check expression syntax

Paired Item Error Resolution

When you see "Paired item not found" or get wrong data from $("<Node>").item:

  1. Identify the break point — Item linking breaks when a node changes item count (e.g., aggregation, split, filter removes items).
  2. Use explicit access instead:
    • $("<Node>").first() — ALWAYS returns first item (safe fallback)
    • $("<Node>").all()[index] — Access by position
    • $("<Node>").itemMatching(currentIndex) — Trace back from current item (preferred in Code node)
  3. In Code node — NEVER use $("<Node>").item. ALWAYS use $("<Node>").itemMatching(index).

JMESPath Parameter Order

n8n uses $jmespath(object, searchString) — this is the OPPOSITE of the JMESPath spec's search(searchString, object).

// CORRECT — object first, search string second
{{ $jmespath($json.data, "[*].name") }}

// WRONG — search string first (JMESPath spec order)
{{ $jmespath("[*].name", $json.data) }}

ALWAYS verify: first argument is the data object, second argument is the query string.


Static Data Pitfalls

$getWorkflowStaticData() has specific constraints:

  • NOT available during manual test execution — returns empty object {}
  • ONLY populated when workflow runs via trigger/webhook in production
  • Data persists across executions but ONLY after successful completion
  • NEVER store large data — keep static data small (IDs, timestamps, counters)
  • May be unreliable during high-frequency parallel executions

Common Error Messages Reference

Error MessageMeaningResolution
Expression evaluation errorGeneric expression parse failureCheck syntax: matching {{ }}, valid JS
Cannot read properties of undefined (reading 'X')Accessing property on null/undefinedAdd null checks: $json.parent?.child
X is not a functionWrong method for data typeCheck type: strings have .extractEmail(), arrays have .average()
Paired item information is missingItem link chain brokenUse .first(), .all(), or .itemMatching()
ReferenceError: $itemIndex is not definedUsed in Code nodeUse loop index or items.indexOf(item)
ReferenceError: $secrets is not definedUsed in Code nodeUse $env or pass via Set node
Invalid left-hand side in assignmentAssignment = inside expressionExpressions are read-only; use Code node for assignment
Unexpected tokenSyntax error in expressionCheck for unmatched brackets, quotes, or template literals

Code Node Specific Restrictions

ALWAYS remember these restrictions when writing Code node logic:

  1. $itemIndexNOT available. Use loop index or items.indexOf(item).
  2. $secretsNOT available. Use $env.SECRET_NAME instead.
  3. $("<Node>").itemNOT recommended. Use $("<Node>").itemMatching(index).
  4. No HTTP requests — use HTTP Request node before/after Code node.
  5. No file system access — use Read/Write Files nodes.
  6. Python: ALWAYS use bracket notation item["json"]["field"], NEVER dot notation.
  7. Python on Cloud: NEVER import external libraries.

$response Context Restriction

$response is ONLY available in HTTP Request node parameter fields:

PropertyReturnsContext
$response.bodyResponse body objectHTTP Request node ONLY
$response.headersResponse headersHTTP Request node ONLY
$response.statusCodeHTTP status codeHTTP Request node ONLY
$response.statusMessageStatus messageHTTP Request node ONLY

If you need HTTP response data in other nodes, the HTTP Request node automatically outputs the response as $json for downstream nodes.


Null/Undefined Handling Strategy

ALWAYS handle potentially missing data with one of these approaches:

  1. $ifEmpty(value, fallback) — Best for simple fallback values
  2. Optional chaining$json.parent?.child?.value for nested access
  3. Ternary{{ $json.field ? $json.field : "default" }} for conditional logic
  4. IIFE for complex logic:
    {{ (function() {
      const val = $json.field;
      if (val === null || val === undefined) return "N/A";
      return val.toString();
    })() }}
    

Type Conversion Quick Reference

FromToMethod
StringNumberNumber($json.field) or parseInt() / parseFloat()
StringBoolean$json.field.toBoolean()
StringDateTime$json.field.toDateTime()
NumberStringString($json.field) or $json.field.format()
NumberBoolean$json.field.toBoolean() (0 = false, else true)
NumberDateTime$json.field.toDateTime() (Unix ms or seconds)
BooleanNumber$json.field.toNumber() (true=1, false=0)
BooleanString$json.field.toString()
ArrayString$json.arr.toJsonString()
ObjectString$json.obj.toJsonString()

Reference Files

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.