{"record":{"id":"f534589485e20be5","repo":"n8n-io/n8n","slug":"arguments-must-be-passed-to-pluck","errorCode":null,"errorMessage":"arguments must be passed to pluck","messagePattern":"arguments must be passed to pluck","errorType":"exception","errorClass":"ExpressionExtensionError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/expression-runtime/src/extensions/array-extensions.ts","lineNumber":39,"sourceCode":"function isEmpty(value: unknown[]): boolean {\n\treturn value.length === 0;\n}\n\nfunction isNotEmpty(value: unknown[]): boolean {\n\treturn value.length > 0;\n}\n\nfunction last(value: unknown[]): unknown {\n\treturn value[value.length - 1];\n}\n\nfunction reverse(value: unknown[]): unknown[] {\n\treturn [...value].reverse();\n}\n\nfunction pluck(value: unknown[], extraArgs: unknown[]): unknown[] {\n\tif (!Array.isArray(extraArgs)) {\n\t\tthrow new ExpressionExtensionError('arguments must be passed to pluck');\n\t}\n\tif (!extraArgs || extraArgs.length === 0) {\n\t\treturn value;\n\t}\n\tconst plucked = value.reduce<unknown[]>((pluckedFromObject, current) => {\n\t\tif (current && typeof current === 'object') {\n\t\t\tconst p: unknown[] = [];\n\t\t\tObject.keys(current).forEach((k) => {\n\t\t\t\t(extraArgs as string[]).forEach((field) => {\n\t\t\t\t\tif (current && field === k) {\n\t\t\t\t\t\tp.push((current as { [key: string]: unknown })[k]);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t\tif (p.length > 0) {\n\t\t\t\tpluckedFromObject.push(p.length === 1 ? p[0] : p);\n\t\t\t}\n\t\t}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/expression-runtime/src/extensions/array-extensions.ts#L21-L57","documentation":"Thrown as ExpressionExtensionError by the .pluck() array extension when extraArgs is not an array. pluck() expects one or more field-name arguments (variadic strings) and iterates them to pull values from each object in the array. The check is a defensive guard that the variadic-args plumbing delivered an array; if it didn't, the call cannot proceed safely.","triggerScenarios":"Calling .pluck() with no arguments at all in a context where the extension harness passes extraArgs as a non-array, or an internal harness bug that fails to box variadic args. In normal n8n expression usage the harness always supplies an array, so this typically indicates a harness/integration issue rather than an end-user typo.","commonSituations":"A custom expression harness or test that invokes pluck directly without boxing args. A regression in the extension-dispatch layer. Misuse via a low-level API rather than the templating surface.","solutions":["Always call pluck with at least one field name: .pluck('name').","If invoking the extension directly, pass extraArgs as an array of strings.","If you see this from normal {{ [...]().pluck('x') }} usage, file a bug against the expression-dispatch harness.","Add a pre-check: if (args.length === 0) return value; before dispatching."],"exampleFix":"// before — invoked without array-boxed args (harness/direct call)\nconst result = pluck(myArray, 'name'); // extraArgs is a string, not an array\n// after — pass args as an array\nconst result = pluck(myArray, ['name']);\n// or in an n8n expression, always pass field names\n// {{ $json.rows.pluck('name') }}","handlingStrategy":"type-guard","validationCode":"function safePluck(arr, fields) {\n  if (!Array.isArray(fields)) throw new TypeError('pluck fields must be an array');\n  if (fields.length === 0) return arr;\n  return arr.map(o => fields.map(f => o?.[f])).flat();\n}","typeGuard":"function arePluckArgsValid(extraArgs) { return Array.isArray(extraArgs) && extraArgs.every(f => typeof f === 'string'); }","tryCatchPattern":"try {\n  result = arr.pluck('name');\n} catch (e) {\n  if (e.name === 'ExpressionExtensionError' && /pluck/i.test(e.message)) {\n    // ensure at least one field-name argument is passed\n  }\n}","preventionTips":["Always pass at least one field name to .pluck(): .pluck('name').","If invoking the extension directly, pass extraArgs as an array of strings.","Report it as a bug if it occurs during normal templating usage."],"tags":["expression-runtime","array-extensions","pluck","argument-validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}