Skip to content

fix: pick deterministic conversion strategy for union receivers - #12283

Draft
Diwak4r wants to merge 3 commits into
deepset-ai:mainfrom
Diwak4r:fix/deterministic-conversion-strategy
Draft

fix: pick deterministic conversion strategy for union receivers#12283
Diwak4r wants to merge 3 commits into
deepset-ai:mainfrom
Diwak4r:fix/deterministic-conversion-strategy

Conversation

@Diwak4r

@Diwak4r Diwak4r commented Aug 10, 2026

Copy link
Copy Markdown

Related Issues

Proposed Changes:

_get_conversion_strategy resolves the strategy for a Union receiver by collecting the strategies of every member into a set and, when neither WRAP nor UNWRAP is among them, falling back to strategies.pop(). Because enum members hash by identity, set.pop() is non-deterministic across processes (ASLR): the same sender/receiver pair could resolve to different conversion strategies on different runs.

Example: converting a ChatMessage to str | list[str] could resolve to either CHAT_MESSAGE_TO_STR or WRAP_CHAT_MESSAGE_TO_STR depending on the process.

This PR replaces the set.pop() with a deterministic scan of the receiver's union members in declaration order, returning the strategy of the first member that yields one. The chosen strategy now honors the order in which the user declared the union members.

How did you test it?

Added regression assertions to test_types_are_compatible_with_conversion:

  • ChatMessage -> str | list[str] resolves to CHAT_MESSAGE_TO_STR
  • ChatMessage -> list[str] | str resolves to WRAP_CHAT_MESSAGE_TO_STR

Under the previous code, the first assertion would flip between the two strategies at random across processes; both now always pass.

Ran the full test_type_utils.py and test_recursive_splitter.py suites: 1122 tests pass.

Notes for the reviewer

The existing WRAP/UNWRAP preference loop is unchanged; only the fallback selection is now deterministic.

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.

@Diwak4r
Diwak4r requested a review from a team as a code owner August 10, 2026 01:21
@Diwak4r
Diwak4r requested review from davidsbatista and a lite review from Copilot and removed request for a team August 10, 2026 01:21
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

@Diwak4r 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.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @Diwak4r, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from davidsbatista August 10, 2026 03:02
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Aug 10, 2026
@HaystackBot
HaystackBot marked this pull request as draft August 10, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-pending PR is in draft until the contributor signs the CLA topic:core topic:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pipeline connection type conversion is non-deterministic across processes

4 participants