Skip to content

AttributeError: 'NoneType' object has no attribute 'append' in accumulate_event when message_start.message.content is null #1799

Description

@tarunbatra

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

Activity

  1. nightcityblade commented on Aug 5, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

  2. dtmeadows-ant commented on Aug 6, 2026

    @dtmeadows-ant
    Contributor

    @tarunbatra sorry for the delay here. message_start.message.content is always an array on responses from our API (it starts as [] and blocks are appended as they stream), so a null there isn't a valid first-party event — I couldn't produce one across text, thinking, tool-use and server-tool streams today. The cases we've seen like this come from an intermediary that builds its own message_start (a gateway/proxy, a mock server, or an example payload copied from abbreviated docs). Closing for now, but if you're seeing it on a direct call to api.anthropic.com, feel free to reopen with a request-id from one of those responses and we'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions