Skip to content

fix: restore auto-variadic socket state in remove_component - #12206

Open
rautaditya2606 wants to merge 2 commits into
deepset-ai:mainfrom
rautaditya2606:fix-remove-component-variadic-socket-reset
Open

fix: restore auto-variadic socket state in remove_component#12206
rautaditya2606 wants to merge 2 commits into
deepset-ai:mainfrom
rautaditya2606:fix-remove-component-variadic-socket-reset

Conversation

@rautaditya2606

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes

  • Updated PipelineBase.remove_component in haystack/core/pipeline/base.py to call socket.__post_init__() and set socket.wrap_input_in_list = True when resetting input sockets of a removed component or when a receiver's remaining senders count drops to $\le 1$.
  • Added unit test test_remove_component_resets_auto_variadic_socket_mutation in test/core/pipeline/test_pipeline_base.py.
  • Added a release note file in releasenotes/notes/.

How did you test it?

hatch run test:unit test/core/pipeline/test_pipeline_base.py
hatch run test:types
hatch run fmt

All 149 pipeline base tests pass cleanly, formatting is verified, and mypy reports zero issues.

Notes for the reviewer

  • Connecting multiple senders to a list[T] socket promotes it to auto-variadic (is_lazy_variadic=True, wrap_input_in_list=False).
  • Previously, remove_component only set socket.senders = [], leaving is_lazy_variadic=True and wrap_input_in_list=False intact. Reusing the component in a single-sender pipeline caused silent input processing bugs (unwanted flattening).
  • Re-invoking socket.__post_init__() safely re-derives variadic status from the socket's declared type annotation, restoring default socket behavior.

Checklist

@rautaditya2606
rautaditya2606 requested a review from a team as a code owner July 31, 2026 05:44
@rautaditya2606
rautaditya2606 requested review from anakin87 and Copilot and removed request for a team July 31, 2026 05:44
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

@rautaditya2606 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/core/pipeline
  base.py
Project Total  

This report was generated by python-coverage-comment-action

@anakin87

Copy link
Copy Markdown
Member

@sjrl could you please take a look when you have some time?

My impression is that the current fix is problematic and corrupts Variadic components during removal.

But you know this part better than me...

@anakin87
anakin87 requested a review from sjrl July 31, 2026 07:01
@rautaditya2606
rautaditya2606 force-pushed the fix-remove-component-variadic-socket-reset branch from 309a149 to 147e038 Compare July 31, 2026 07:06
@rautaditya2606

Copy link
Copy Markdown
Contributor Author

@sjrl could you please take a look when you have some time?

My impression is that the current fix is problematic and corrupts Variadic components during removal.

But you know this part better than me...

Thanks for the feedback. I've updated the implementation so only the removed component's socket state is restored. Receiver sockets in the active pipeline are no longer modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PipelineBase.remove_component does not reset auto-variadic socket state when reusing components

3 participants