Skip to content

Commit 2ea244f

Browse files
Aftabbsclaude
andcommitted
fix: wrap long line in chat_prompt_builder and add release notes
- Break line 272 in chat_prompt_builder.py to satisfy E501 (max 120 chars) - Add reno release note for the dataclass mutation fix Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2a9e5b7 commit 2ea244f

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

haystack/components/builders/chat_prompt_builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ def run(
269269
compiled_template = self._env.from_string(message.text)
270270
rendered_text = compiled_template.render(template_variables_combined)
271271
# use dataclasses.replace to avoid in-place mutation of the copied message
272-
rendered_message: ChatMessage = replace(deepcopy(message), _content=[TextContent(text=rendered_text)])
272+
rendered_message: ChatMessage = replace(
273+
deepcopy(message), _content=[TextContent(text=rendered_text)]
274+
)
273275
processed_messages.append(rendered_message)
274276
else:
275277
processed_messages.append(message)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed in-place mutation of ``ChatMessage`` dataclass instances in
5+
``ChatPromptBuilder``, ``DynamicChatPromptBuilder``, and
6+
``HuggingFaceLocalChatGenerator``. Mutations now use
7+
``dataclasses.replace()`` instead of direct attribute assignment,
8+
preventing unintended side-effects when the same message object is
9+
reused across multiple pipeline runs.

0 commit comments

Comments
 (0)