Error Observed
File "/app/.venv/lib/python3.10/site-packages/anthropic/lib/streaming/_beta_messages.py", line 55, in __iter__
for item in self._iterator:
File "/app/.venv/lib/python3.10/site-packages/anthropic/lib/streaming/_beta_messages.py", line 116, in __stream__
self.__final_message_snapshot = accumulate_event(
File "/app/.venv/lib/python3.10/site-packages/anthropic/lib/streaming/_beta_messages.py", line 416, in accumulate_event
current_snapshot.content.append(
AttributeError: 'NoneType' object has no attribute 'append'
Bug
According to API docs and SDK types, content should always be List[ContentBlock]
|
content: List[ContentBlock] |
but there are places where content: null is geenrated in the SDK. Like:
|
return cast(ParsedMessage[ResponseFormatT], ParsedMessage.construct(**cast(Any, event.message.to_dict()))) |
Environment
anthropic version: 0.52.0 (also reproduces against main as of this filing — same unguarded append)
- Python:
3.10.20
- Trigger:
client.messages.stream
client.beta.messages.stream
Error Observed
Bug
According to API docs and SDK types,
contentshould always beList[ContentBlock]anthropic-sdk-python/src/anthropic/types/message.py
Line 22 in e9f5e44
but there are places where
content: nullis geenrated in the SDK. Like:anthropic-sdk-python/src/anthropic/lib/streaming/_messages.py
Line 452 in f5c30d0
Environment
anthropicversion:0.52.0(also reproduces againstmainas of this filing — same unguarded append)3.10.20client.messages.streamclient.beta.messages.stream