Repository navigation
Python: fix(core): handle None text safely in Message.text property - #8688
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
Conversation
Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
|
Thank you for proposing this change. I am closing this PR for now because its Related Issue section says |
Motivation & Context
In
Message.text, the property concatenates text across all text content items via' '.join(content.text for content in self.contents if content.type == 'text'). When a message contains a text content item whosetextisNone(e.g. created viaContent('text', text=None)or parsed from a payload with null text), Python raises aTypeError: sequence item: expected str instance, NoneType found.Filtering out
Nonevalues ensures thatmessage.textoperates safely without crashing on null text content items, consistent with null text handling inContent.__str__andfrom_function_result.Description & Review Guide
Message.textinpython/packages/core/agent_framework/_types.py, addedand content.text is not Noneto the generator expression.test_message_text_handles_none_text_contentsintest_types.pyverifying messages with null text content items return the concatenated string cleanly without raisingTypeError.Related Issue
None
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.