Skip to content

fix: Fix appending None to a list in State when the source key is missing#10990

Merged
sjrl merged 1 commit intomainfrom
fix-merge-values
Mar 31, 2026
Merged

fix: Fix appending None to a list in State when the source key is missing#10990
sjrl merged 1 commit intomainfrom
fix-merge-values

Conversation

@sjrl
Copy link
Copy Markdown
Contributor

@sjrl sjrl commented Mar 31, 2026

Related Issues

Proposed Changes:

Fix ToolInvoker._merge_tool_outputs silently appending None to list-typed state when a tool's outputs_to_state source key is absent from the tool result. This is a common scenario with PipelineTool wrapping a pipeline that has conditional branches where not all outputs are always produced even if defined in outputs_to_state. The mapping is now skipped entirely when the source key is not present in the result dict.

How did you test it?

Added a new unit test based on what was described in the issue

Notes for the reviewer

I decided not to update merge_lists since the fix in ToolInvoker prevents None from reaching merge_lists. It's also possible that None is an intended to be passed to merge_lists which is still allowed if the source key is present in the tool dict and the value it points to is None.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@sjrl sjrl requested a review from a team as a code owner March 31, 2026 07:13
@sjrl sjrl requested review from julian-risch and removed request for a team March 31, 2026 07:13
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Mar 31, 2026 7:14am

Request Review

@coveralls
Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 23785192769

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.001%) to 92.9%

Files with Coverage Reduction New Missed Lines %
components/tools/tool_invoker.py 4 97.11%
Totals Coverage Status
Change from base Build 23754030523: 0.001%
Covered Lines: 15872
Relevant Lines: 17085

💛 - Coveralls

Copy link
Copy Markdown
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

Looks good to me! 👍 Explanation of what caused the issue and how we fixed is thorough. This PR unblocks the 2.27 release. Thanks for addressing the issue so quickly.

@sjrl sjrl merged commit 4686335 into main Mar 31, 2026
23 checks passed
@sjrl sjrl deleted the fix-merge-values branch March 31, 2026 07:45
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.

Agent state corrupted with None entries when outputs_to_state source key absent from tool result

3 participants