deepset-ai/haystack · error · ComponentError

Variadic input '{self.name}' must have a type argument, e.g.

Error message

Variadic input '{self.name}' must have a type argument, e.g. Variadic[int]. Got bare {inner_type!r} without a type argument.

What it means

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.

Source

Thrown at haystack/core/component/types.py:107

            self.is_lazy_variadic = False
            self.is_greedy = False

        # We need to "unpack" the type inside the Variadic annotation, otherwise the pipeline connection api will try
        # to match `Annotated[type, HAYSTACK_VARIADIC_ANNOTATION]`.
        #
        # Note1: Variadic is expressed as an annotation of one single type, so the return value of get_args will
        # always be a one-item tuple.
        #
        # Note2: a pipeline always passes a list of items when a component input is declared as Variadic, so the
        # type itself always wraps an iterable of the declared type. For example, Variadic[int] is eventually an
        # alias for Iterable[int]. Since we're interested in getting the inner type `int`, we call `get_args`
        # twice: the first time to get `list[int]` out of `Variadic`, the second time to get `int` out of `list[int]`.
        if self.is_lazy_variadic or self.is_greedy:
            outer_args = get_args(self.type)
            inner_type = outer_args[0]
            inner_args = get_args(inner_type)
            if not inner_args:
                raise ComponentError(
                    f"Variadic input '{self.name}' must have a type argument, e.g. Variadic[int]. "
                    f"Got bare {inner_type!r} without a type argument."
                )
            self.type = inner_args[0]


class InputSocketTypeDescriptor(TypedDict):
    """
    Describes the type of `InputSocket`.
    """

    type: type | UnionType
    is_mandatory: bool


@dataclass
class OutputSocket:
    """

View on GitHub (pinned to e318778c9b)

Solutions

  1. Add a concrete type argument to the inner type, e.g. Variadic[list[int]]
  2. Fully parameterize nested generics: Variadic[list[list[int]]] rather than Variadic[list[list]]
  3. If the element type truly varies, pick the common base type or use object/Any explicitly

Example fix

// before
component.inputs = [InputSocket(name="vals", type=Variadic[list])]

// after
component.inputs = [InputSocket(name="vals", type=Variadic[list[int]])]
Defensive patterns

Strategy: validation

Validate before calling

from typing import get_args
from haystack.core.component.types import Variadic

def check_variadic(t):
    args = get_args(t)
    if args and any(get_origin(a) and not get_args(a) for a in args):
        raise TypeError(f"{t}: inner type of Variadic must be parameterized, e.g. Variadic[list[int]]")

Type guard

def is_fully_parameterized(t) -> bool:
    return not (get_origin(t) and not get_args(t))

Try / catch

try:
    build_component(...)
except ComponentError as e:
    if "Variadic" in str(e):
        logging.error("Parameterize the Variadic inner type: %s", e)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30). Data as JSON: /api/errors/f4d068da359e17ca. Report an issue: GitHub.