Skip to content

AttachmentDto / Moshi fails when API returns file_size: null on attachments (watch/query surfaces as NETWORK_FAILED / code 1000) #6428

@jasoniLabs

Description

@jasoniLabs

Environment

  • Library: io.getstream:stream-chat-android-client
  • Version: 5.17.23 (likely affects other versions with the same DTO)
  • Integration: ChannelClient.watch() / channel query responses that include messages with image (or other) attachments

Problem
The HTTP API returns 200 and valid JSON, but the Android SDK reports failure with:

  • ChatErrorCode.NETWORK_FAILED (stream code 1000)
  • Message: Response is failed. See cause
  • statusCode: -1
    So the failure is client-side deserialization, not a failed HTTP call or empty messages.

Root cause (observed)
DownstreamMessageDto / AttachmentDto models file_size as a non-null Int (default 0). When the server JSON includes an attachment with an explicit null:

Image
"attachments": [
  {
    "type": "image",
    "image_url": "https://example.com/image.jpeg",
    "file_size": null
  }
]

Moshi fails to parse (JsonDataException: expected int, got null). That exception is wrapped as NETWORK_FAILED / 1000, which is misleading when debugging.

Expected behavior
The SDK should tolerate file_size: null the same way it tolerates a missing field—e.g. treat null as “unknown” and coerce to 0 or use Int? in AttachmentDto with safe mapping to domain models.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions