{"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/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/runtime/server/astro-component.ts#L1-L36","documentation":"Every compiled .astro component is wrapped by baseCreateComponent, whose wrapper validates the call shape before delegating: exactly 3 arguments (props, slots, children) with props as a non-null object. The Astro renderer and compiler always call components with that shape, so a failure means the component factory was invoked outside the normal rendering contract. This is almost always direct programmatic invocation rather than JSX rendering.","triggerScenarios":"Calling an .astro component factory directly: Component() with no args, Component({x:1}) with only props (args.length !== 3), or Component('title') passing a primitive as the first argument (typeof args[0] !== 'object'). Also triggered by wrappers/HOCs that forward a reduced argument list, e.g. (props) => factory(props).","commonSituations":"Rendering .astro components programmatically in unit tests or scripts instead of through JSX; utility functions that call component factories manually; custom renderers or integrations that invoke Astro components with an invented signature; code migrated from older internal APIs.","solutions":["Render the component through JSX (<Component {...props} />) or through the supported programmatic API (experimental_AstroContainer from astro/container) instead of calling the factory by hand","If you must invoke the factory, pass all three arguments: Component(props, slots, children) with props as an object","Fix any wrapper/HOC to forward the full argument list: (...args) => factory(...args)","Check for isAstroComponentFactory(fn) before treating a module export as a callable render function"],"exampleFix":"// before\nconst html = await Component({ name: 'x' });\n\n// after\nimport { experimental_AstroContainer as AstroContainer } from 'astro/container';\nconst container = await AstroContainer.create();\nconst html = await container.renderToString(Component, { props: { name: 'x' } });","handlingStrategy":"type-guard","validationCode":"import { isAstroComponentFactory } from 'astro/runtime/server/index.js';\n\nif (!isAstroComponentFactory(Component)) {\n  throw new TypeError('Not an Astro component factory');\n}","typeGuard":"function isCallableAstroComponent(fn: unknown): fn is (...args: any[]) => any {\n  return typeof fn === 'function' && (fn as any).isAstroComponentFactory === true;\n}","tryCatchPattern":null,"preventionTips":["Never call .astro component factories by hand; render them as <Component /> or via experimental_AstroContainer","Forward full argument lists in wrappers: (...args) => factory(...args)","Check the isAstroComponentFactory flag before treating an export as renderable"],"tags":["astro","component","arguments","rendering"],"backgroundTag":"invalid-component-arguments","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}