{"record":{"id":"1a9c3f1b8bce4071","repo":"n8n-io/n8n","slug":"keys-and-values-not-of-equal-length","errorCode":null,"errorMessage":"keys and values not of equal length","messagePattern":"keys and values not of equal length","errorType":"exception","errorClass":"ExpressionExtensionError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/expression-runtime/src/extensions/function-extensions.ts","lineNumber":28,"sourceCode":"\n\tlet curr = start;\n\tfor (let i = 0; i < size; i++) {\n\t\tif (start < end) {\n\t\t\tarr[i] = curr++;\n\t\t} else {\n\t\t\tarr[i] = curr--;\n\t\t}\n\t}\n\n\treturn arr;\n};\n\nconst zip = (keys: unknown[], values: unknown[]): unknown => {\n\tif (!Array.isArray(keys) || !Array.isArray(values)) {\n\t\tthrow new ExpressionExtensionError('keys and values must be arrays');\n\t}\n\tif (keys.length !== values.length) {\n\t\tthrow new ExpressionExtensionError('keys and values not of equal length');\n\t}\n\tconst result: Record<string, unknown> = {};\n\tfor (let i = 0; i < keys.length; i++) {\n\t\tresult[keys[i] as string] = values[i];\n\t}\n\treturn result;\n};\n\nconst average = (...args: number[]) => {\n\treturn aAverage(args);\n};\n\nconst not = (value: unknown): boolean => {\n\treturn !value;\n};\n\nfunction ifEmpty<T, V>(value: V, defaultValue: T) {\n\tif (arguments.length !== 2) {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/expression-runtime/src/extensions/function-extensions.ts#L10-L46","documentation":"`zip` also requires the two arrays to have EQUAL length (`keys.length !== values.length`); otherwise the resulting object would have undefined values for the missing positions.","triggerScenarios":"A header array with 5 entries zipped against a row array with 4; mismatched parallel lists from upstream.","commonSituations":"Ragged source data (CSV rows with fewer columns than the header); one source pruned entries the other kept.","solutions":["Pad the shorter array (e.g. fill with `null`) or truncate the longer one to equal length.","Validate `keys.length === values.length` upstream in a Code node.","Re-emit the upstream data so both lists are guaranteed parallel."],"exampleFix":"// before\n{{ zip(['a','b','c'], [1,2]) }}\n// after\n{{ zip(['a','b','c'], [1,2,null]) }}","handlingStrategy":"validation","validationCode":"const { keys, values } = $json;\nif (keys.length !== values.length) {\n  throw new Error(`zip(): length mismatch (${keys.length} vs ${values.length})`);\n}\nreturn $json;","typeGuard":"const sameLength = (a: unknown[], b: unknown[]): boolean => a.length === b.length;","tryCatchPattern":null,"preventionTips":["Pad or truncate arrays to equal length upstream.","Validate `keys.length === values.length` before the expression runs.","Re-emit upstream data so parallel lists stay parallel."],"tags":["expression","array","length-mismatch","validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}