SuperComponent drops Variadic and GreedyVariadic socket semantics from wrapped pipelines

オープン
#13,991 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #13992 @Cyber-Marty による — マージされずにクローズ

評価

この issue はまだ評価されていません。

説明

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!

主要言語
Python
スター
27.2k
フォーク
3.5k
平均マージ
1日 18時間
マージ済み PR(30日)
254

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

deepset-ai/haystack のほかの issue

deepset-ai/haystack の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。