Repository navigation
fix(msteams): cancel unread Graph error response bodies - #117664
vincentkoc merged 2 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 4:19 AM ET / 08:19 UTC. ClawSweeper reviewWhat this changesThe PR makes Microsoft Teams attachment downloads cancel unread Microsoft Graph response bodies before releasing their guarded fetch dispatchers. Merge readinessThis PR is still necessary because current Priority: P2 Review scores
Verification
How this fits togetherMicrosoft Teams attachment downloads fetch message metadata, hosted-content collections, and hosted-content bytes through an SSRF-guarded Graph client. The attachment layer owns each returned response and its dispatcher-release callback after parsing or an error path completes. flowchart LR
A[Teams message] --> B[Graph attachment downloader]
B --> C[Guarded Graph fetch]
C --> D[Response and release callback]
D --> E[Parse metadata or media]
E --> F[Cancel unread response body]
F --> G[Close pinned dispatcher]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +6, Tests +98. Total +104 across 2 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Merge this focused attachment-layer repair after the normal current-head merge gate; keep the shared SSRF guard unchanged because other callers may own streaming response lifecycles differently. Do we have a high-confidence way to reproduce the issue? Yes, from current source and the added regression shape: failed message and Is this the best way to solve the issue? Yes. A local helper at the Microsoft Teams response-owner boundary fixes all affected guarded Graph responses while preserving the shared guard contract for streaming and non-attachment consumers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 26cf4e6130a8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
a219482 to
c37c2c9
Compare
|
Merged via squash.
|
* origin/main: fix: stop lost cancellations, false success, and stuck Codex compaction (openclaw#117902) fix(cli): reject incomplete hosted video downloads (openclaw#117893) refactor(board): remove duplicate in-memory store (openclaw#117353) refactor: consolidate Teams and error helpers (openclaw#117907) fix(msteams): cancel unread Graph error response bodies (openclaw#117664) fix(imessage): rewind the recovery cursor when chat.db is replaced at the same path (openclaw#117788) feat(browser): relay CDP compat for Puppeteer clients (chrome-devtools-mcp) (openclaw#117915)
) * fix(msteams): cancel unread Graph error response bodies * fix(msteams): release every guarded Graph response safely --------- Co-authored-by: Peter Steinberger <[email protected]>
* origin/main: fix: stop lost cancellations, false success, and stuck Codex compaction (openclaw#117902) fix(cli): reject incomplete hosted video downloads (openclaw#117893) refactor(board): remove duplicate in-memory store (openclaw#117353) refactor: consolidate Teams and error helpers (openclaw#117907) fix(msteams): cancel unread Graph error response bodies (openclaw#117664) fix(imessage): rewind the recovery cursor when chat.db is replaced at the same path (openclaw#117788) feat(browser): relay CDP compat for Puppeteer clients (chrome-devtools-mcp) (openclaw#117915)
Summary
Cancel unread Microsoft Teams Graph response bodies before releasing their guarded fetch resources.
The final branch is intentionally narrow:
$valueresponsesThe unrelated shared Gateway test-helper changes were removed.
What Problem This Solves
fetchWithSsrFGuard()returns both aResponseand arelease()callback. The callback clears guard state and closes its dispatcher, but it does not consume or cancel an unread response body.The message and
$valuenon-ok paths released the guard with unread bodies. The collection path attempted to cancel first, but awaited that cancellation. Awaiting can deadlock when response capture has cloned and teed the stream because cancellation waits for the other tee branch.Slow, large, or stalled Graph error bodies can therefore retain the pinned connection and dispatcher after the caller has finished handling the failure. Small finite JSON errors may already be buffered, so this PR does not claim every Graph error leaks a connection.
Microsoft Graph defines JSON error response bodies, and Undici requires callers to consume or cancel response bodies:
Fix
Add one local
releaseGraphResponse()owner helper that:release()callback.All three guarded Graph response owners use this helper. The shared SSRF guard remains unchanged because streaming consumers have different response-lifecycle contracts.
Evidence
Exact reviewed head:
c37c2c9206ee995a7cfce583f4c42424731bdd85pnpm test extensions/msteams/src/attachments/graph.test.tsrun_2c674c8df4cc$valueresponse cancellationrelease()only: release completed after about 101 ms, while the server-side socket and response remained open after 1 secondrelease(): release completed in about 1 ms and the socket/response closed in about 5 msgit diff --checkclean0.98Scope
extensions/msteams/src/attachments/graph.ts, +10/-4, net +6extensions/msteams/src/attachments/graph.test.ts, +98