Skip to content

fix(msteams): add timeouts to SharePoint file send requests - #104288

Merged
steipete merged 24 commits into
openclaw:mainfrom
Alix-007:alix/msteams-sharepoint-file-send-timeouts
Jul 16, 2026
Merged

steipete merged 24 commits into
openclaw:mainfrom
Alix-007:alix/msteams-sharepoint-file-send-timeouts

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes MS Teams group/channel file sends that could hang indefinitely during Graph token acquisition, SharePoint upload, sharing-link creation, chat-member lookup, drive-item metadata lookup, or response-body reads.

It also removes an unsafe sharing fallback: a generic Graph 403 is not proof that chat-member permission is absent. Microsoft documents 403 for insufficient permission, missing license, and conditional-access claims; per-chat RSC grants are not ordinary token roles.

Why This Change Was Made

  • Wrap the full Graph/SharePoint request lifecycle in aborting deadlines, including token acquisition and response-body reads.
  • Keep Graph control-plane work on the 30 second MS Teams request deadline.
  • Give SharePoint content PUTs a 5 minute base plus transfer budget at 256 KiB/s, matching the adjacent MS Teams upload policy.
  • Require a successful group-chat member lookup before creating a users-scoped link. A 403, timeout, transport error, 5xx response, token error, or empty member set now fails the send instead of widening access to the organization.
  • Keep channel file sends explicitly organization-scoped.
  • Document least-privileged ChatMember.Read.All, per-chat ChatMember.Read.Chat RSC, and the broader Chat.Read.All alternative.

User Impact

MS Teams file sends no longer wait forever when Graph or SharePoint stalls. Slow valid large uploads retain enough transfer time. Group-chat file access can no longer widen to the whole organization after an ambiguous member-lookup denial.

Release note: MS Teams SharePoint file sends now time out instead of hanging, and group-chat member lookup failures fail closed instead of widening files to the organization.

Evidence

Exact head: cc90663e7218904270665f00106c0f313d356f8a.

Focused validation:

node scripts/run-vitest.mjs extensions/msteams/src/graph-upload.test.ts extensions/msteams/src/request-timeout.test.ts
-> 2 files passed, 22 tests passed

oxfmt --check (touched source/test/docs files)
-> clean

pnpm docs:list
-> clean

git diff --check
-> clean

Coverage includes:

  • token acquisition timeout before upload starts;
  • slow large upload success beyond the 30 second control-plane window;
  • abort at the size-aware transfer deadline;
  • stalled response-body reads;
  • successful users-scoped link creation for returned chat members;
  • fail-closed timeout, 403, 503, token-failure, and empty-recipient paths;
  • organization scope for the separate channel path.

Controlled loopback transport proof from the contributor exercised the production helpers over real Node HTTP transport:

slow-upload-success: elapsedMs=31068, result=success
createLink-control-plane-stall: TimeoutError after 30016ms, server socket closed after 30005ms
upload-transfer-stall: TimeoutError at the upload deadline, server socket closed at the deadline

Fresh pre-push autoreview accepted two findings (RSC cannot be inferred from JWT roles; ChatMember.Read.All is the least-privileged application permission), both fixed. Final autoreview reported no accepted/actionable findings.

Delegated Testbox check:changed reached the repository gates but hit only the stale-head max-lines baseline ratchet; the PR is mergeable and hosted exact-head CI is the authoritative post-push gate. True Microsoft tenant behavior remains blocked because no approved Teams/Graph credential was available; the proof above is controlled transport and focused regression coverage, not a live tenant claim.

@openclaw-barnacle openclaw-barnacle Bot added channel: msteams Channel integration: msteams size: M labels Jul 11, 2026
@Alix-007
Alix-007 force-pushed the alix/msteams-sharepoint-file-send-timeouts branch from a717fe4 to 6907e10 Compare July 11, 2026 07:39
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 15, 2026, 2:24 AM ET / 06:24 UTC.

Summary
The PR adds aborting, transfer-aware deadlines to MS Teams SharePoint uploads and fixed deadlines to related Graph requests, with expanded timeout and least-privilege fallback tests.

PR surface: Source +82, Tests +464. Total +546 across 4 files.

Reproducibility: yes. from source, with high confidence: current main uses unbounded SharePoint and related Graph fetch lifecycles, while the controlled transport scenario demonstrates the exact stalls and socket-abort behavior after the fix. An authenticated Microsoft tenant reproduction was not available.

Review metrics: 1 noteworthy metric.

  • Sharing fallback policy: 1 fallback narrowed. Organization-scope widening changes from a broad member-lookup failure fallback to explicit HTTP 403 only, which affects both upgrade compatibility and file-access scope.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Obtain owner approval for the 403-only organization-scope fallback contract.
  • Refresh the branch against current main and rerun the exact-head review.

Risk before merge

  • [P1] Existing installations that currently complete a send by widening to an organization link after a transient member-lookup failure will instead fail the file send on timeouts, network errors, 5xx responses, token failures, or empty recipient sets.
  • [P1] An explicit Graph 403 still widens access to organization scope, so the owner should confirm that 403 reliably represents the intended permission limitation rather than another condition where delivery should fail closed.
  • [P1] The loopback proof exercises production HTTP transport but not an authenticated Microsoft tenant, leaving a small residual risk around real Graph error shapes and SharePoint response behavior.

Maintainer options:

  1. Approve the fail-closed contract (recommended)
    Accept that non-403 member-lookup failures will stop existing file sends in exchange for preventing ambiguous organization-wide permission widening.
  2. Define a narrower compatibility fallback
    Specify which additional Graph outcomes can safely preserve delivery, then add focused access-scope and upgrade tests before merging.
  3. Split the policy change
    Pause this branch and separate the uncontroversial timeout fix from the organization-scope fallback decision if owner consensus is not available.

Next step before merge

  • [P2] A maintainer should decide the permanent sharing fallback contract, then request an exact-head refresh; no concrete automated code repair remains.

Maintainer decision needed

  • Question: Should MS Teams SharePoint sends widen to organization scope only after an explicit Graph HTTP 403, while every timeout, transport failure, 5xx response, token failure, or empty recipient set aborts delivery?
  • Rationale: Repository policy treats removed fallbacks and fail-closed behavior as compatibility-sensitive, and this choice directly trades successful delivery during Graph failures against least-privilege file access.
  • Likely owner: steipete — This person is the strongest available routing candidate from the MS Teams feature history and was explicitly brought into the PR timeline during the security-boundary review.
  • Options:
    • Approve 403-only fallback (recommended): Adopt the PR's least-privilege policy so only an explicit permission-denied response can widen the sharing link and all ambiguous failures stop delivery.
    • Preserve selected availability fallbacks: Define and test a narrow additional set of Graph outcomes that may safely widen access rather than failing the send.
    • Separate timeout and sharing policy: Land only the bounded request behavior and move the sharing-scope decision into a separately reviewed security-policy change.

Security
Cleared: The diff adds no dependencies or secret-handling surface and strengthens least-privilege behavior by preventing ambiguous failures from silently widening SharePoint access.

Review details

Best possible solution:

Retain the full-lifecycle, size-aware timeout implementation and merge only after the MS Teams owner explicitly accepts the 403-only organization-scope fallback contract and the exact head is refreshed against current main.

Do we have a high-confidence way to reproduce the issue?

Yes from source, with high confidence: current main uses unbounded SharePoint and related Graph fetch lifecycles, while the controlled transport scenario demonstrates the exact stalls and socket-abort behavior after the fix. An authenticated Microsoft tenant reproduction was not available.

Is this the best way to solve the issue?

Yes for the aborting, full-lifecycle, transfer-aware timeout design; the 403-only fallback is the safest least-privilege policy, but its deliberate availability tradeoff still requires explicit owner acceptance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bda52883657b.

Label changes

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR provides after-fix production-helper proof over real Node HTTP transport showing slow-upload success plus deadline-triggered TimeoutError and socket closure for stalled control-plane and upload requests.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a channel-specific reliability and permission-scope fix with meaningful but bounded impact on MS Teams group and channel file sends.
  • merge-risk: 🚨 compatibility: The PR intentionally converts several previously successful fallback cases into hard delivery failures for existing installations.
  • merge-risk: 🚨 message-delivery: Timeouts, transport errors, 5xx responses, token failures, and empty recipient sets will now suppress the file send instead of producing an organization link.
  • merge-risk: 🚨 security-boundary: The patch changes when uploaded SharePoint files may receive organization-wide sharing links and therefore alters an authorization boundary.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR provides after-fix production-helper proof over real Node HTTP transport showing slow-upload success plus deadline-triggered TimeoutError and socket closure for stalled control-plane and upload requests.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides after-fix production-helper proof over real Node HTTP transport showing slow-upload success plus deadline-triggered TimeoutError and socket closure for stalled control-plane and upload requests.
Evidence reviewed

PR surface:

Source +82, Tests +464. Total +546 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 152 70 +82
Tests 2 465 1 +464
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 617 71 +546

What I checked:

Likely related people:

  • steipete: The MS Teams implementation history includes the major official-SDK and file-delivery evolution associated with this area, and the PR timeline explicitly routed the current security-boundary review toward this person. (role: feature-history owner and likely decision reviewer; confidence: medium; files: extensions/msteams/src/graph-upload.ts, extensions/msteams/src/messenger.ts)
  • Alix-007: The same contributor authored the already-merged file-consent upload timeout work that introduced the transfer-budget policy now reused by this SharePoint change. (role: recent adjacent timeout contributor; confidence: high; commits: 3f8fdb45271b, 0c8220ebf9aa; files: extensions/msteams/src/request-timeout.ts, extensions/msteams/src/monitor-handler.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-12T10:05:45.447Z sha 3b5a022 :: needs changes before merge. :: [P1] Scale the SharePoint upload deadline with payload size
  • reviewed 2026-07-13T03:43:16.615Z sha d0766d5 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T11:44:32.794Z sha d3c3ce8 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T15:41:32.067Z sha 2aec785 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T16:01:40.561Z sha 2aec785 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T02:22:33.441Z sha aa5c429 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T10:31:14.622Z sha f84048f :: found issues before merge. :: [P1] Fail closed when chat-member lookup times out
  • reviewed 2026-07-14T11:00:43.450Z sha f84048f :: found issues before merge. :: [P1] Fail closed when chat-member lookup times out

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated exact head: 0ae42ef74ce58ae97ee39070c8dd855b2d71b73c.

Changes since the last review:

  • Fixed the CI lint failure (prefer-promise-reject-errors) in the stalled-fetch test helper.
  • Moved the aborting SharePoint timeout helper into extensions/msteams/src/request-timeout.ts, the existing MS Teams timeout owner.
  • Merged current upstream/main normally; no rebase or force-push.
  • Updated the PR body with a controlled partial proof through production uploadAndShareSharePoint() / getDriveItemProperties() and real loopback HTTP stalls. This is explicitly not claimed as live Microsoft tenant proof.

Re-ran locally because Crabbox/Testbox is unavailable in this environment:

git diff --check upstream/main...HEAD -- extensions/msteams/src/graph-upload.ts extensions/msteams/src/request-timeout.ts extensions/msteams/src/graph-upload.test.ts
node_modules/.bin/oxlint extensions/msteams/src/graph-upload.ts extensions/msteams/src/request-timeout.ts extensions/msteams/src/graph-upload.test.ts
node_modules/.bin/oxfmt --check --threads=1 extensions/msteams/src/graph-upload.ts extensions/msteams/src/request-timeout.ts extensions/msteams/src/graph-upload.test.ts
node scripts/run-vitest.mjs extensions/msteams/src/graph-upload.test.ts

Loopback proof transcript is in the PR body.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 11, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated exact head: 355cc9e1f6c6567349853ee077b3ded75dff6ce3.

Changes since the last completed review:

  • SharePoint content PUT now uses a transfer-specific 5 minute deadline (MSTEAMS_SHAREPOINT_UPLOAD_TIMEOUT_MS = 300000).
  • Graph control-plane calls (getChatMembers, createLink, getDriveItemProperties) keep the existing 30 second request timeout.
  • Added focused regression coverage for slow upload success after the 30s control-plane window and for control-plane abort at 30s.
  • Updated the PR body with a real loopback transcript showing:
    • slow upload succeeds after ~31s,
    • stalled createLink aborts at ~30s and closes the socket,
    • stalled content upload aborts at ~300s and closes the socket.

Validation rerun locally because Crabbox/Testbox is unavailable here:

git diff --check upstream/main...HEAD -- extensions/msteams/src/graph-upload.ts extensions/msteams/src/request-timeout.ts extensions/msteams/src/graph-upload.test.ts
node_modules/.bin/oxlint extensions/msteams/src/graph-upload.ts extensions/msteams/src/request-timeout.ts extensions/msteams/src/graph-upload.test.ts
node_modules/.bin/oxfmt --check --threads=1 extensions/msteams/src/graph-upload.ts extensions/msteams/src/request-timeout.ts extensions/msteams/src/graph-upload.test.ts
node scripts/run-vitest.mjs extensions/msteams/src/graph-upload.test.ts

Focused test result: 1 file passed, 11 tests passed.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated exact head: f1f83bfee4e451fe92226d76dc96082aff18707c.

This is the final head after:

  • the transfer/control-plane timeout split and slow-success/stall proof added at 355cc9e1f6c6567349853ee077b3ded75dff6ce3,
  • a test-only CI lint fix at b9ab8dddcf6ad2ea64e5eeb04a12e3a7e0527250, and
  • a normal gh pr update-branch merge; no rebase or force-push.

PR body is updated with the current head, validation commands, and the loopback proof transcript.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Jul 14, 2026
@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 15, 2026
@steipete steipete self-assigned this Jul 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Jul 16, 2026
@steipete
steipete merged commit 292e8c3 into openclaw:main Jul 16, 2026
117 of 119 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…#104288)

* fix(msteams): add timeouts to SharePoint file send requests

* fix(msteams): clean up SharePoint timeout proof

* fix(msteams): use transfer deadline for SharePoint uploads

* test(msteams): normalize SharePoint abort rejection reasons

* fix(msteams): size SharePoint upload deadline by file length

* chore(deadcode): allowlist test-only timeout constant exports

* fix(msteams): harden SharePoint sharing deadlines

Co-authored-by: Alix-007 <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…#104288)

* fix(msteams): add timeouts to SharePoint file send requests

* fix(msteams): clean up SharePoint timeout proof

* fix(msteams): use transfer deadline for SharePoint uploads

* test(msteams): normalize SharePoint abort rejection reasons

* fix(msteams): size SharePoint upload deadline by file length

* chore(deadcode): allowlist test-only timeout constant exports

* fix(msteams): harden SharePoint sharing deadlines

Co-authored-by: Alix-007 <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: msteams Channel integration: msteams docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants