Skip to content

fix: preserve MockChatGenerator deserialization input - #13471

Merged
davidsbatista merged 5 commits into
deepset-ai:mainfrom
wozhenbang2004:fix/mock-chat-generator-deserialization-input
Oct 30, 2026
Merged

davidsbatista merged 5 commits into
deepset-ai:mainfrom
wozhenbang2004:fix/mock-chat-generator-deserialization-input

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Related Issues

No existing issue found.

Proposed Changes

Loading the same serialized MockChatGenerator configuration twice currently fails: from_dict() replaces the caller's response dictionaries with ChatMessage instances and serialized callback names with callables. For example, a second load of a predefined-response configuration raises TypeError: argument of type 'ChatMessage' is not iterable.

Copy init_parameters before deserializing its values and construct the generator from that copy. The original configuration remains serialized and can be reused.

Extend the existing parametrized serialization roundtrip test to verify unchanged input and two successful loads for predefined responses, response functions, echo mode, and streaming callbacks. Add a release note.

How did you test it?

  • Before the fix, the strengthened roundtrip regression produced 3 failures and 1 pass.
  • hatch run test:unit test/components/generators/chat/test_mock.py test/core/test_serialization.py test/utils/test_callable_serialization.py test/utils/test_deserialization.py -q --no-cov: 79 passed.
  • hatch run fmt-check haystack/components/generators/chat/mock.py test/components/generators/chat/test_mock.py: passed.
  • hatch run test:types --no-native-parser haystack/components/generators/chat/mock.py test/components/generators/chat/test_mock.py: passed.
  • All pre-commit hooks applicable to the changed files passed.

The default mypy native parser crashed while probing CPU affinity through psutil in this container. The supported --no-native-parser option completed successfully. Full-suite and live-provider tests were not run.

Notes for the reviewer

This contribution was generated with an AI assistant. The diff received an independent source review and the relevant regression tests and checks were run. Human author review has not yet occurred.

@wozhenbang2004
wozhenbang2004 requested a review from a team as a code owner October 28, 2026 16:14
@wozhenbang2004
wozhenbang2004 requested review from davidsbatista and removed request for a team October 28, 2026 16:14
@vercel

vercel Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @wozhenbang2004, 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 October 28, 2026 17:22
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Oct 28, 2026
@HaystackBot
HaystackBot marked this pull request as draft October 28, 2026 17:22
@HaystackBot
HaystackBot marked this pull request as ready for review October 29, 2026 01:03
@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Oct 29, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

Thanks for signing the CLA, @wozhenbang2004! 🎉 This PR is now ready for review again and the reviewer has been re-assigned.

@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
haystack-docs Ready Ready Preview Oct 30, 2026 11:25am UTC

Request Review

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/generators/chat
  mock.py
Project Total  

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

@HaystackBot
HaystackBot removed the request for review from davidsbatista October 29, 2026 16:25
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Oct 29, 2026
@HaystackBot
HaystackBot marked this pull request as draft October 29, 2026 16:25
@davidsbatista
davidsbatista marked this pull request as ready for review October 29, 2026 16:28
@davidsbatista
davidsbatista self-requested a review October 29, 2026 16:28

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

LGTM, thanks!

@davidsbatista
davidsbatista enabled auto-merge (squash) October 29, 2026 16:29
@HaystackBot
HaystackBot marked this pull request as draft October 29, 2026 16:50
auto-merge was automatically disabled October 29, 2026 16:50

Pull request was converted to draft

@davidsbatista
davidsbatista marked this pull request as ready for review October 29, 2026 17:05
@davidsbatista
davidsbatista enabled auto-merge (squash) October 29, 2026 17:05
@HaystackBot
HaystackBot marked this pull request as draft October 29, 2026 17:22
auto-merge was automatically disabled October 29, 2026 17:22

Pull request was converted to draft

@wozhenbang2004

Copy link
Copy Markdown
Contributor Author

Thanks for the review! The CLA was signed on b8261d9, but the new merge commit is still waiting for license/cla. The CLA Assistant link now returns “Bad credentials” and says there is no CLA to sign. Could you take a look at the integration? I couldn't find a recheck option.

@davidsbatista
davidsbatista marked this pull request as ready for review October 30, 2026 08:54
@HaystackBot
HaystackBot marked this pull request as draft October 30, 2026 09:25
@davidsbatista
davidsbatista marked this pull request as ready for review October 30, 2026 10:47
@HaystackBot
HaystackBot marked this pull request as draft October 30, 2026 10:51
@davidsbatista
davidsbatista marked this pull request as ready for review October 30, 2026 11:20
@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Oct 30, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

Thanks for signing the CLA, @wozhenbang2004! 🎉 This PR is now ready for review again and the reviewer has been re-assigned.

This branch was successfully deployed

1 active deployment
Preview — 2075fadb Deployed Oct 30, 2026 by vercel[bot]
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.

3 participants