Skip to content

[Bug]: MS Teams: inline pasted images fail to download (hostedContents contentBytes always null) #43648

@TroyCava

Description

@TroyCava

Bug type

Crash (process/app exits or hangs)

Summary

Bug Description

When a user pastes an image inline into a Microsoft Teams chat (Ctrl+V / Cmd+V), OpenClaw fails to download the image. The gateway logs show "graph media fetch empty" for every pasted image. File attachments (drag-and-drop / paperclip) work correctly.

Root Cause Analysis

After investigating the source code in extensions/msteams/src/attachments/graph.ts, I found two issues:

Issue 1: contentBytes is always null in the list response

The downloadGraphHostedContent() function calls GET /chats/{chatId}/messages/{messageId}/hostedContents and iterates over the returned items, checking contentBytes:

const contentBytes = typeof item.contentBytes === "string" ? item.contentBytes : "";
if (!contentBytes) {
  continue; // <-- Every item is skipped because contentBytes is always null
}

Microsoft's Graph API does not return contentBytes in the list response. The list endpoint returns { id, contentBytes: null, contentType: null } for each item. To get the actual image bytes, you must either:

  • Call GET .../hostedContents/{id} (returns base64 contentBytes in JSON)
  • Call GET .../hostedContents/{id}/$value (returns raw binary)

I verified this by directly calling the Graph API with the bot's credentials:

  • List response: { id: "aWQ9eF8w...", contentBytes: null, contentType: null }
  • Individual $value response: 322,314 bytes, Content-Type: image/png

Issue 2: Conversation ID format mismatch (personal chats)

The buildMSTeamsGraphMessageUrls() function uses conversationId from the Bot Framework activity to construct Graph API URLs. For personal (DM) chats, the Bot Framework provides IDs in the format a:13IoTSM38fCC_eud..., but the Graph API expects 19:[email protected]. This causes the Graph message lookup to fail with 404 or construct invalid URLs.

Environment

  • OpenClaw version: 2026.3.8 (latest as of 2026-03-11)
  • MS Teams plugin: @openclaw/msteams (bundled extension)
  • Bot type: Single Tenant
  • Graph API permissions: Chat.Read.All, ChannelMessage.Read.All (Application, admin-consented)
  • OS: Ubuntu 22.04 on Azure VM

Steps to Reproduce

  1. Configure OpenClaw with MS Teams bot (single tenant, Graph permissions granted)
  2. Open a personal chat (DM) with the bot in Teams
  3. Paste an image (Ctrl+V) and add a text message
  4. Check gateway logs

Expected Behavior

Image should be downloaded and passed to the agent as an attachment.

Actual Behavior

Gateway logs show:

"html attachment summary"
"graph media fetch empty"

The message is dispatched to the agent without any image attachment.

Suggested Fix

In downloadGraphHostedContent(), when the list response returns items with contentBytes: null, fetch each item individually via GET .../hostedContents/{id}/$value to retrieve the raw bytes. Also consider normalizing the conversation ID from Bot Framework format to Graph API format for personal chats.

Workaround

Users can drag-and-drop image files (from File Explorer / Finder) into the Teams chat instead of pasting. File attachments use a different code path (SharePoint/reference attachments) that works correctly.

Steps to reproduce

Copy Paste image into Chat

Expected behavior

Same as Drag drop image file

Actual behavior

Hangs, doesnt recognise anything has happened.

OpenClaw version

Todays latest version

Operating system

Ubantu

Install method

Docker VM Azure

Model

Todays latest Opus

Provider / routing chain

Openclaw Tail Scale

Config file / key location

No response

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingbug:crashProcess/app exits unexpectedly or hangs

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