{"record":{"id":"33c0deb52e01da6e","repo":"withastro/astro","slug":"expected-second-parameter-to-be-an-array-received","errorCode":null,"errorMessage":"Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as an item of an array. Ex: Astro.slots.render('default', [[\"Hello\", \"World\"]])","messagePattern":"Expected second parameter to be an array, received a (.+?)\\. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as an item of an array\\. Ex: Astro\\.slots\\.render\\('default', \\[\\[\"Hello\", \"World\"\\]\\]\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/core/render/slots.ts","lineNumber":61,"sourceCode":"\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t\tenumerable: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic has(name: string) {\n\t\tif (!this.#slots) return false;\n\t\treturn Boolean(this.#slots[name]);\n\t}\n\n\tpublic async render(name: string, args: any[] = []) {\n\t\tif (!this.#slots || !this.has(name)) return;\n\n\t\tconst result = this.#result;\n\t\tif (!Array.isArray(args)) {\n\t\t\tthis.#logger.warn(\n\t\t\t\tnull,\n\t\t\t\t`Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as an item of an array. Ex: Astro.slots.render('default', [[\"Hello\", \"World\"]])`,\n\t\t\t);\n\t\t} else if (args.length > 0) {\n\t\t\tconst slotValue = this.#slots[name];\n\t\t\tconst component = typeof slotValue === 'function' ? await slotValue(result) : await slotValue;\n\n\t\t\t// Astro\n\t\t\tconst expression = getFunctionExpression(component);\n\t\t\tif (expression) {\n\t\t\t\tconst slot = async () =>\n\t\t\t\t\ttypeof expression === 'function' ? expression(...args) : expression;\n\t\t\t\treturn await renderSlotToString(result, slot).then((res) => {\n\t\t\t\t\treturn res;\n\t\t\t\t});\n\t\t\t}\n\t\t\t// JSX\n\t\t\tif (typeof component === 'function') {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/render/slots.ts#L43-L79","documentation":"Astro.slots.render(name, args) spreads the second parameter's items as function arguments into a slot defined as an inline expression. The contract is a single array; passing anything else (string, number, object) makes the render misbehave, so render() warns about the received type and shows how to pass an array as one argument ([[...]]) when that is the intent.","triggerScenarios":"Calling Astro.slots.render('default', 'Hello'), Astro.slots.render('default', 42), or any non-array second argument; or wanting a slot parameter that is itself an array and passing it un-nested.","commonSituations":"Porting component APIs where a scalar was passed; refactoring a callback-slot component so it receives one array parameter; copy-pasting slot render calls between components with different signatures.","solutions":["Wrap the arguments in an array: Astro.slots.render('default', ['Hello'])","If the slot must receive a single array argument, nest it: Astro.slots.render('default', [['Hello', 'World']])","Type the call site (args: any[]) so the wrong shape is caught by tooling before runtime"],"exampleFix":"// before\nconst html = await Astro.slots.render('default', 'Hello');\n\n// after — one string argument\nconst html = await Astro.slots.render('default', ['Hello']);\n// or: single array argument\nconst html = await Astro.slots.render('default', [['Hello', 'World']]);","handlingStrategy":"type-guard","validationCode":"if (!Array.isArray(args)) args = [args]; // normalize before render\nconst html = await Astro.slots.render('default', args);","typeGuard":"function isArgsArray(args: unknown): args is any[] {\n  return Array.isArray(args);\n}","tryCatchPattern":null,"preventionTips":["Always pass an array literal as the second argument to slots.render","When the slot parameter itself is an array, wrap it in another array","Keep component slot signatures documented next to the render call"],"tags":["slots","api-misuse","arguments"],"backgroundTag":"invalid-argument-value","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}