{"record":{"id":"e465bc39eb71711f","repo":"withastro/astro","slug":"invalidcomponentargs","errorCode":"InvalidComponentArgs","errorMessage":"Invalid arguments passed to <${name}> component.","messagePattern":"Invalid arguments passed to <(.+?)> component\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/runtime/server/astro-component.ts","lineNumber":18,"sourceCode":"import { AstroError, AstroErrorData } from '../../core/errors/index.js';\nimport type { PropagationHint } from '../../types/public/internal.js';\nimport type { AstroComponentFactory } from './render/index.js';\n\nfunction validateArgs(args: unknown[]): args is Parameters<AstroComponentFactory> {\n\tif (args.length !== 3) return false;\n\tif (!args[0] || typeof args[0] !== 'object') return false;\n\treturn true;\n}\nfunction baseCreateComponent(\n\tcb: AstroComponentFactory,\n\tmoduleId?: string,\n\tpropagation?: PropagationHint,\n): AstroComponentFactory {\n\tconst name = moduleId?.split('/').pop()?.replace('.astro', '') ?? '';\n\tconst fn = (...args: Parameters<AstroComponentFactory>) => {\n\t\tif (!validateArgs(args)) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.InvalidComponentArgs,\n\t\t\t\tmessage: AstroErrorData.InvalidComponentArgs.message(name),\n\t\t\t});\n\t\t}\n\t\treturn cb(...args);\n\t};\n\tObject.defineProperty(fn, 'name', { value: name, writable: false });\n\t// Add a flag to this callback to mark it as an Astro component\n\tfn.isAstroComponentFactory = true;\n\tfn.moduleId = moduleId;\n\tfn.propagation = propagation;\n\treturn fn;\n}\n\ninterface CreateComponentOptions {\n\tfactory: AstroComponentFactory;\n\tmoduleId?: string;\n\tpropagation?: PropagationHint;","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/runtime/server/astro-component.ts#L1-L36","documentation":"Every Astro component factory is wrapped by `baseCreateComponent`, which validates invocation through `validateArgs`: it requires exactly 3 arguments and that the first argument is a non-null object (the props). If a component is called with the wrong shape (e.g. by bypassing the compiler's call convention or manually invoking the factory), Astro throws `InvalidComponentArgs`.","triggerScenarios":"Manually invoking a compiled `.astro` component factory with the wrong number of arguments, or with a non-object first argument — typically from hand-written code rather than the Astro compiler's generated calls.","commonSituations":"Calling a `.astro` component as a plain function `MyComponent({ x: 1 })` instead of via the renderer; a corrupted/older compiled output that calls the factory incorrectly; a custom integration invoking component factories directly with the wrong signature.","solutions":["Render `.astro` components through Astro's normal rendering pipeline (the compiler-generated call), not by manual function invocation.","If invoking programmatically, pass the expected 3-tuple: `(props, metadata, AstroGlobals)`-style arguments matching `AstroComponentFactory`.","Regenerate compiled output (`astro build`/`astro sync`) in case of stale artifacts."],"exampleFix":"// before — manual call with wrong arity\nconst html = MyComponent({ name: 'x' })\n\n// after — render via Astro's API (e.g. render() from 'astro:render')\nimport { render } from 'astro:render'\nconst html = await render(MyComponent, { name: 'x' })","handlingStrategy":"validation","validationCode":"function isValidComponentCall(args) {\n  return Array.isArray(args) && args.length === 3 &&\n    args[0] != null && typeof args[0] === 'object';\n}","typeGuard":"function isAstroComponentCall(args) {\n  return Array.isArray(args) && args.length === 3 &&\n    typeof args[0] === 'object' && args[0] !== null;\n}","tryCatchPattern":"null","preventionTips":["Render .astro components via Astro's render pipeline, not manual calls.","Do not invoke component factories directly with props only.","Regenerate compiled output after compiler upgrades."],"tags":["runtime","components","compiler","rendering"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}