SuperComponent drops Variadic and GreedyVariadic socket semantics from wrapped pipelines

Abierto
#13,991 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #13992 de @Cyber-Marty — cerrado sin fusionar

Evaluación

Este issue todavía no se ha evaluado.

Descripción

handled internally P2

Describe the bug
Wrapping a pipeline whose exposed entry socket is Variadic[T] or GreedyVariadic[T] (for example DocumentJoiner, StringJoiner, or BranchJoiner) inside SuperComponent strips the variadic annotation from the outer SuperComponent input socket.

As a result:

  1. Connecting two or more upstream components to a SuperComponent-wrapped StringJoiner or BranchJoiner raises PipelineConnectError because the outer socket is exposed as str instead of Variadic[str] or GreedyVariadic[str].
  2. Connecting two upstream list[Document] producers to a SuperComponent-wrapped DocumentJoiner auto-promotes the outer list[Document] socket with wrap_input_in_list=False, flattening incoming document lists before passing them to SuperComponent.run(). That causes DocumentJoiner(join_mode="merge", weights=[0.7, 0.3]) to crash with zip() argument 2 is longer than argument 1, and silently corrupts join_mode="reciprocal_rank_fusion" scores (producing 1.98387... instead of 1.0).
  3. Calling sc.run(documents=[[d_a], [d_b]]) directly double-wraps the input inside self.pipeline.run(), raising PipelineRuntimeError: 'list' object has no attribute 'id'.

Error message

haystack.core.errors.PipelineRuntimeError: The following component failed to run:
Component name: 'joiner'
Component type: 'DocumentJoiner'
Error: zip() argument 2 is longer than argument 1

And on direct sc.run(documents=[[d_a], [d_b]]):

haystack.core.errors.PipelineRuntimeError: The following component failed to run:
Component name: 'joiner'
Component type: 'DocumentJoiner'
Error: 'list' object has no attribute 'id'

And on StringJoiner / BranchJoiner fan-in:

haystack.core.errors.PipelineConnectError: Component 'sc' cannot accept multiple inputs to 'texts'. It is already connected to component 'a', and it can only accept inputs from multiple senders if its type is list, Optional[list], or union of list types.

Expected behavior

  • When all inner sockets mapped to a SuperComponent input share a declared Variadic[T] or GreedyVariadic[T] contract, the exposed SuperComponent socket preserves Variadic[T] or GreedyVariadic[T].
  • Multi-sender outer pipeline runs and direct SuperComponent.run() / run_async() calls forward variadic items to the inner pipeline without flattening or double-wrapping, matching direct DocumentJoiner / StringJoiner / BranchJoiner behavior.

Additional context
haystack/core/super_component/utils.py already includes _is_variadic_type and _unwrap_variadics, but _SuperComponent._resolve_input_types_from_mapping inspects self.pipeline.inputs(), which exposes InputSocket.type after InputSocket.__post_init__ has already stripped Variadic / GreedyVariadic into is_lazy_variadic / is_greedy flags.

To Reproduce

from haystack import Document, Pipeline, SuperComponent, component
from haystack.components.joiners import BranchJoiner, DocumentJoiner, StringJoiner


@component
class DocSource:
    def __init__(self, docs: list[Document]) -> None:
        self._docs = docs

    @component.output_types(documents=list[Document])
    def run(self) -> dict[str, list[Document]]:
        return {"documents": self._docs}


d_a = Document(id="shared", content="doc", score=0.9)
d_b = Document(id="shared", content="doc", score=0.4)

inner = Pipeline()
inner.add_component("joiner", DocumentJoiner(join_mode="merge", weights=[0.7, 0.3]))
sc = SuperComponent(inner)

# 1. Outer multi-branch fan-in crashes DocumentJoiner merge
outer = Pipeline()
outer.add_component("s1", DocSource([d_a]))
outer.add_component("s2", DocSource([d_b]))
outer.add_component("sc", sc)
outer.connect("s1.documents", "sc.documents")
outer.connect("s2.documents", "sc.documents")
outer.run({})  # PipelineRuntimeError: zip() argument 2 is longer than argument 1

# 2. Direct SuperComponent call double-wraps [[d_a], [d_b]]
sc.run(documents=[[d_a], [d_b]])  # PipelineRuntimeError: 'list' object has no attribute 'id'

FAQ Check

System:

  • OS: Windows 11 (reproduced on Python 3.12)
  • Haystack version: main (979c6fd)

👋 Hello there! This issue will be handled internally and isn't open for external contributions. If you'd like to contribute, please take a look at issues labeled contributions welcome or good first issue. We'd really appreciate it!

Lenguaje dominante
Python
Estrellas
27.2k
Forks
3.5k
Merge medio
1 d 18 h
PR fusionados (30 d)
254

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de deepset-ai/haystack

Todos los issues de deepset-ai/haystack

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.