Skip to content

MSTeams: hostedContents collection response missing contentBytes - images not downloaded in group chats #5448

@onetec-claude-code

Description

@onetec-claude-code

Bug

Images sent in Teams group chats are not received by the bot. The gateway logs show:

[msteams] html attachment summary
[msteams] graph media fetch empty

Repeated for every message containing images. Only inline emoji from the HTML body are captured — actual uploaded images/screenshots are silently dropped.

Root Cause

In extensions/msteams/src/attachments/graph.ts, the downloadGraphHostedContent function fetches the collection endpoint:

GET /chats/{chatId}/messages/{messageId}/hostedContents

This returns metadata with id, but contentBytes is always null in the collection response. Microsoft Graph does not include binary content in collection endpoints.

The code then checks contentBytes and skips the item since it is empty:

const contentBytes = typeof item.contentBytes === "string" ? item.contentBytes : "";
if (!contentBytes) continue; // <-- always skipped!

Fix

Each hosted content item needs to be fetched individually using the $value endpoint:

GET /chats/{chatId}/messages/{messageId}/hostedContents/{contentId}/$value

This returns the raw binary image data with the correct Content-Type header.

Verification

Manually tested with curl against the same chat/message:

Endpoint Result
/hostedContents (collection) 1 item returned, contentBytes: null, contentType: null
/hostedContents/{id}/$value 200 OK, 160KB PNG image, correct content

The Graph API permissions are correctly configured (Chat.Read.All, ChatMessage.Read.All with admin consent) — the issue is purely in how the response is consumed.

Environment

  • Clawdbot version: 2026.1.24-3
  • Plugin: @clawdbot/msteams 2026.1.24
  • Channel type: group chat
  • Graph permissions: Chat.Read.All, ChatMessage.Read.All (both granted with admin consent)
  • Node.js: v22.22.0

Workaround

None currently — images in group chats are silently dropped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions