{"record":{"id":"f4d068da359e17ca","repo":"deepset-ai/haystack","slug":"variadic-input-self-name-must-have-a-type-argu","errorCode":null,"errorMessage":"Variadic input '{self.name}' must have a type argument, e.g. Variadic[int]. Got bare {inner_type!r} without a type argument.","messagePattern":"Variadic input '(.+?)' must have a type argument, e\\.g\\. Variadic\\[int\\]\\. Got bare (.+?) without a type argument\\.","errorType":"exception","errorClass":"ComponentError","httpStatus":null,"severity":"error","filePath":"haystack/core/component/types.py","lineNumber":107,"sourceCode":"            self.is_lazy_variadic = False\n            self.is_greedy = False\n\n        # We need to \"unpack\" the type inside the Variadic annotation, otherwise the pipeline connection api will try\n        # to match `Annotated[type, HAYSTACK_VARIADIC_ANNOTATION]`.\n        #\n        # Note1: Variadic is expressed as an annotation of one single type, so the return value of get_args will\n        # always be a one-item tuple.\n        #\n        # Note2: a pipeline always passes a list of items when a component input is declared as Variadic, so the\n        # type itself always wraps an iterable of the declared type. For example, Variadic[int] is eventually an\n        # alias for Iterable[int]. Since we're interested in getting the inner type `int`, we call `get_args`\n        # twice: the first time to get `list[int]` out of `Variadic`, the second time to get `int` out of `list[int]`.\n        if self.is_lazy_variadic or self.is_greedy:\n            outer_args = get_args(self.type)\n            inner_type = outer_args[0]\n            inner_args = get_args(inner_type)\n            if not inner_args:\n                raise ComponentError(\n                    f\"Variadic input '{self.name}' must have a type argument, e.g. Variadic[int]. \"\n                    f\"Got bare {inner_type!r} without a type argument.\"\n                )\n            self.type = inner_args[0]\n\n\nclass InputSocketTypeDescriptor(TypedDict):\n    \"\"\"\n    Describes the type of `InputSocket`.\n    \"\"\"\n\n    type: type | UnionType\n    is_mandatory: bool\n\n\n@dataclass\nclass OutputSocket:\n    \"\"\"","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/component/types.py#L89-L125","documentation":"Variadic inputs collect multiple connections into one input, but the element type must be explicit so Haystack knows what to type-check against. When a Variadic input's inner type has no type arguments (e.g. Variadic[list] or a bare generic), __post_init__ cannot resolve the element type and raises this ComponentError.","triggerScenarios":"Declaring an InputSocket with type=Variadic[X] where X is itself a bare generic without type parameters (e.g. Variadic[list], Variadic[dict], Variadic[list[list]]), including via the Variadic wrapper used for greedy/loop variadics.","commonSituations":"Writing Variadic[list] instead of Variadic[list[int]]; passing typing constructs like Variadic[Sequence] or Variadic[list[tuple]] whose innermost type has parameters the author forgot; type aliases that erase parameters.","solutions":["Add a concrete type argument to the inner type, e.g. Variadic[list[int]]","Fully parameterize nested generics: Variadic[list[list[int]]] rather than Variadic[list[list]]","If the element type truly varies, pick the common base type or use object/Any explicitly"],"exampleFix":"// before\ncomponent.inputs = [InputSocket(name=\"vals\", type=Variadic[list])]\n\n// after\ncomponent.inputs = [InputSocket(name=\"vals\", type=Variadic[list[int]])]","handlingStrategy":"validation","validationCode":"from typing import get_args\nfrom haystack.core.component.types import Variadic\n\ndef check_variadic(t):\n    args = get_args(t)\n    if args and any(get_origin(a) and not get_args(a) for a in args):\n        raise TypeError(f\"{t}: inner type of Variadic must be parameterized, e.g. Variadic[list[int]]\")","typeGuard":"def is_fully_parameterized(t) -> bool:\n    return not (get_origin(t) and not get_args(t))","tryCatchPattern":"try:\n    build_component(...)\nexcept ComponentError as e:\n    if \"Variadic\" in str(e):\n        logging.error(\"Parameterize the Variadic inner type: %s\", e)","preventionTips":["Never write bare generics like Variadic[list] or Variadic[dict]","Fully parameterize nested generics down to the leaf types","Type-check component definitions with mypy to catch bare generics"],"tags":["python","typing","generics","component-inputs","haystack"],"backgroundTag":"bare-generic-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}