Teams channel file attachments fixed
Teams channel file attachments were silently failing — uploads reached the bot but delivered nothing, while false Graph API calls generated misleading error logs for every @mention message.
When users attached files to Teams channel messages, the bot saw the text but never received the file content. The system reported valid permissions and successful fetches, yet returned empty every time — a silent content loss masked by empty error handlers.
The root cause was a detection flaw: the code treated every text/html attachment as a file candidate, triggering the Graph API fallback for @mention cards and other HTML chrome that aren't actual files. When the fallback fired, it called ${messageUrl}/attachments — a Graph API sub-resource that doesn't exist for channel messages, returning 404s that were swallowed by empty catch blocks.
File attachments in Teams channels now work correctly. The fallback only triggers when real <attachment id> tags are present, and attachments are sourced from the correct location in the Graph response. Failures surface as logged warnings instead of disappearing silently.
View Original GitHub Description
Summary
Channel file attachments (users uploading files into a Teams channel conversation) were silently failing because the Graph media fallback was triggering on any HTML attachment — including @mention cards — and calling a nonexistent Graph sub-resource.
Root cause
hasHtmlAttachmentininbound-media.tstreated alltext/htmlattachments as file candidates, including mention cards- Graph fallback path called
\${messageUrl}/attachments— a sub-resource that does not exist in the Graph API - Errors were swallowed by empty
catch {}blocks, masking the real failure
Fix
- Gate fallback on presence of
<attachment id="...">tags in the HTML content - Source attachments from the
chatMessage.attachmentsarray returned by the main message fetch (correct Graph path) - Replace empty
catch {}with proper error logging
Fixes #58617 Fixes #51749
Test plan
- @mention cards no longer trigger fallback
- Real file attachments route through the correct Graph path
- Errors are now logged instead of swallowed
- Manual: upload a file to a Teams channel with the bot
🤖 Generated with Claude Code