n8n-io/n8n · error · Error
nodeJson() requires a non-empty JSON path.
Error message
nodeJson() requires a non-empty JSON path.
What it means
nodeJson() builds a {{ $('Node').item.json.<path> }} reference. normalizePath() splits the path on '.' (or accepts an array) and rejects the result if there are zero segments or any empty segment after trimming. This guards against malformed dotted paths that would produce invalid expression syntax.
Source
Thrown at packages/@n8n/workflow-sdk/src/expression/index.ts:89
type NodeJsonReference = NodeInstance<string, string, unknown> | string;
const IDENTIFIER_PATH_SEGMENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
function resolveNodeName(node: NodeJsonReference): string {
return typeof node === 'string' ? node : node.name;
}
function escapeNodeName(nodeName: string): string {
return nodeName.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
}
function normalizePath(path: string | readonly string[]): string[] {
const segments = typeof path === 'string' ? path.split('.') : [...path];
const normalized = segments.map((segment) => segment.trim());
if (normalized.length === 0 || normalized.some((segment) => segment.length === 0)) {
throw new Error('nodeJson() requires a non-empty JSON path.');
}
return normalized;
}
function formatPathSegment(segment: string): string {
if (IDENTIFIER_PATH_SEGMENT.test(segment)) {
return `.${segment}`;
}
return `[${JSON.stringify(segment)}]`;
}
/**
* Build an expression that references JSON data from a specific node by name.
*
* Prefer this over `$json` when a value comes from an AI subnode, a fan-in
* branch, or any node other than the immediate main-flow predecessor.View on GitHub (pinned to 5ac6606e81)
Solutions
- Provide a concrete non-empty dotted path like 'message.chat.id' or a non-empty array of segments.
- If the path is dynamic, validate each segment is non-empty before calling nodeJson().
- Trim and check the path string before passing it.
Example fix
// before
const ref = nodeJson('Set User', '');
// after
const ref = nodeJson('Set User', 'profile.email'); Defensive patterns
Strategy: validation
Validate before calling
// Validate the path before calling nodeJson().
function validPath(p: string | readonly string[]): boolean {
const segs = (typeof p === 'string' ? p.split('.') : [...p]).map((s) => s.trim());
return segs.length > 0 && segs.every((s) => s.length > 0);
}
if (!validPath(path)) throw new Error('path must be non-empty with no blank segments');
const ref = nodeJson(node, path); Prevention
- Always pass a concrete dotted path like 'message.chat.id'.
- If the path is dynamic, validate each segment is non-empty after trimming.
- Avoid leading/trailing/double dots in dotted strings.
When it happens
Trigger: nodeJson(node, ''), nodeJson(node, '.'), nodeJson(node, 'a.'), nodeJson(node, '.a'), nodeJson(node, 'a..b'), nodeJson(node, ['','b']), nodeJson(node, []), or nodeJson(node, ' ').
Common situations: Path is built dynamically from missing/empty data; LLM passes an empty path; user copies a partial path; trailing dot typo.
Related errors
- nodeJson() requires a node or node name.
- expr(newCredential('${value.name}')) is invalid. Use newCred
- expr() requires a string argument, but received ${typeof val
- topK must be an integer >= 1, got ${k}
- intersection(): expected array arg, e.g. .intersection([1, 2
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/d6e5b72715efd77a.
Report an issue: GitHub.