← Back to PRs

#18716: msteams: fix DM image delivery + user target routing

by ktsushilofficial open 2026-02-17 00:44 View on GitHub →
channel: msteams size: S
## Summary - **Problem:** Two MSTeams issues - (1) target=user: returns 403 BotNotInConversationRoster, (2) Images silently dropped in DM - **Why it matters:** Users cannot send messages to DMs or send images via MSTeams - **What changed:** Modified conversation lookup to prefer "personal" type, added buffer parameter support for inline base64 media - **What did NOT change:** No other channels, no config changes, no API surface changes beyond MSTeams ## Change Type - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Docs - [ ] Security hardening - [ ] Chore/infra ## Scope - [x] Gateway / orchestration - [x] Skills / tool execution - [ ] Auth / tokens - [ ] Memory / storage - [x] Integrations - [ ] API / contracts - [ ] UI / DX - [ ] CI/CD / infra ## Linked Issue/PR - Closes #18693 ## User-visible / Behavior Changes - DM messages with target=user: now route correctly to personal conversations - Inline base64 images now delivered properly to MSTeams DMs ## Security Impact - New permissions/capabilities? No - Secrets/tokens handling changed? No - New/changed network calls? No - Command/tool execution surface changed? No (added parameter support, no new capabilities) - Data access scope changed? No ## Repro + Verification ### Environment - OS: Linux (Ubuntu 24.04) - Runtime: Node 22 - Integration: MSTeams ### Steps 1. Send message with target=user:<aadObjectId> 2. Observe 403 error before fix, success after 3. Send message with buffer/base64 image to DM 4. Observe silent drop before fix, image delivered after ## Compatibility / Migration - Backward compatible? Yes - Config/env changes? No - Migration needed? No ## Failure Recovery - How to disable/revert: git revert the commit - Files to restore: 5 files changed ## Risks and Mitigations - None - minimal fix targeting specific MSTeams issues <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR fixes two MSTeams issues: (1) `target=user:` routing returning 403 BotNotInConversationRoster errors by preferring "personal" conversation references over stale group/channel ones, and (2) adding `buffer` parameter support for inline base64 media delivery in DMs. - **User routing fix (send-context.ts):** The conversation lookup now filters all stored references for a user and prefers "personal" type conversations, which work reliably for proactive messaging. This correctly addresses the 403 error when the bot has both personal and group conversation references for the same user. - **Buffer/media support (send.ts, outbound.ts, types):** Adds a `buffer` string parameter through the outbound adapter pipeline, converting base64 data to a data URL format for media delivery. - **Critical issue:** The buffer-to-data-URL conversion in `send.ts` passes the resulting `data:image/...;base64,...` string to `loadWebMedia()`, which does not handle data URLs (only HTTP URLs and local file paths). This will cause a runtime error when `buffer` is provided without `mediaUrl`, meaning the DM image delivery fix will not work as intended. - **Incomplete pipeline wiring:** The `buffer` field is added to `ChannelOutboundContext` but `createChannelOutboundContextBase()` in `deliver.ts` never populates it, so buffer data cannot flow through the standard delivery pipeline. <h3>Confidence Score: 2/5</h3> - The user routing fix is sound, but the buffer/media delivery path has a runtime error that needs to be resolved before merging. - Score of 2 reflects that half the PR (user routing fix) is correct and safe, while the other half (buffer/base64 media delivery) will fail at runtime due to passing data URLs to loadWebMedia() which doesn't support them. The delivery pipeline also doesn't wire buffer data through to the adapter. - `extensions/msteams/src/send.ts` needs the most attention — the buffer-to-loadWebMedia path will throw. `src/infra/outbound/deliver.ts` also needs attention to wire buffer through `createChannelOutboundContextBase`. <sub>Last reviewed commit: 0acbbc6</sub> <!-- greptile_other_comments_section --> <sub>(1/5) You can manually trigger the agent by mentioning @greptileai in a comment!</sub> <!-- /greptile_comment -->

Most Similar PRs