Skip to content

fix(amazon-bedrock): use dataclasses.replace instead of mutating StreamingChunk#3273

Merged
bogdankostic merged 1 commit into
mainfrom
fix/mutatingSharedInfos
May 6, 2026
Merged

fix(amazon-bedrock): use dataclasses.replace instead of mutating StreamingChunk#3273
bogdankostic merged 1 commit into
mainfrom
fix/mutatingSharedInfos

Conversation

@ArzelaAscoIi
Copy link
Copy Markdown
Member

@ArzelaAscoIi ArzelaAscoIi commented May 5, 2026

Summary

Replace direct attribute mutation of StreamingChunk.component_info with dataclasses.replace() to avoid unexpected side effects on shared dataclass instances.

Warning triggered

/home/haystackd/.local/lib/python3.12/site-packages/haystack_integrations/components/generators/amazon_bedrock/chat/utils.py:630: Warning: Mutating attribute 'component_info' on an instance of 'StreamingChunk' can lead to unexpected behavior by affecting other parts of the pipeline that use the same dataclass instance. Use `dataclasses.replace(instance, component_info=new_value)` instead. See https://docs.haystack.deepset.ai/docs/custom-components#requirements for details.

…amingChunk

Co-authored-by: Cursor <cursoragent@cursor.com>
@ArzelaAscoIi ArzelaAscoIi requested a review from a team as a code owner May 5, 2026 10:58
@ArzelaAscoIi ArzelaAscoIi requested review from bogdankostic and removed request for a team May 5, 2026 10:58
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Coverage report (amazon_bedrock)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat
  utils.py
Project Total  

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

@bogdankostic bogdankostic merged commit c79ab82 into main May 6, 2026
16 checks passed
@bogdankostic bogdankostic deleted the fix/mutatingSharedInfos branch May 6, 2026 07:06
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.

2 participants