Skip to content

feat(msteams): support resumable upload sessions for files > 4MB#21739

Open
krishna-warfade wants to merge 12 commits intoopenclaw:mainfrom
krishna-warfade:dev_krishna
Open

feat(msteams): support resumable upload sessions for files > 4MB#21739
krishna-warfade wants to merge 12 commits intoopenclaw:mainfrom
krishna-warfade:dev_krishna

Conversation

@krishna-warfade
Copy link
Copy Markdown

@krishna-warfade krishna-warfade commented Feb 20, 2026

Summary

  • Problem: The MS Teams upload functions only used the simple PUT /content Graph API endpoint, which has a hard 4MB file size limit.
  • Why it matters: Users sending large files (images, documents, recordings) via MS Teams could silently fail on upload.
  • What changed: Added an uploadChunked() helper that creates a Microsoft Graph upload session (/createUploadSession) and uploads in ~3.1MB chunks (a required multiple of 320 KiB). Both uploadToOneDrive and uploadToSharePoint now auto-detect files > 4MB and use this path.
  • What did NOT change: The ≤ 4MB simple upload path is unchanged. All existing callers work without modification.

Change Type

  • Feature

Scope

  • Integrations

Linked Issue/PR

  • Resolves the TODO comment: For files >4MB, implement resumable upload session.

User-visible / Behavior Changes

Previously, sending a file > 4MB via the MS Teams bot would fail at the upload step. After this change, files of any size upload successfully. No config changes required.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? Yes — adds POST .../createUploadSession + chunked PUT requests to a temporary Microsoft-issued upload URL.
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • Mitigation: The temporary uploadUrl is pre-authenticated and short-lived (Microsoft-issued). No bearer token is sent in chunk PUT requests — follows Microsoft's recommended pattern exactly.

Repro + Verification

Steps

  1. Attempt to send a file > 4MB as an attachment via the MS Teams bot.
  2. Previously: upload failed (413 or similar error from Microsoft Graph).
  3. Now: upload completes successfully and a sharing link is returned.

Expected

File uploads and a sharing link is returned successfully regardless of file size.

Actual

File uploads and a sharing link is returned successfully.

Evidence

  • Unit tests added covering:
    • Simple upload (≤ 4MB): verifies single PUT /content call
    • Chunked upload (> 4MB): verifies POST /createUploadSession + multiple PUTs with correct Content-Range headers
    • Covers both uploadToOneDrive and uploadToSharePoint

Human Verification (required)

  • Verified scenarios: ≤ 4MB path unchanged. 5MB file correctly triggers session creation and splits into 2 chunks with correct Content-Range headers per Microsoft Graph spec.
  • Edge cases checked: Exactly 4MB boundary (uses simple path), multi-chunk boundary alignment.
  • What I did NOT verify: Live end-to-end test with real Microsoft Graph credentials (requires a live Teams tenant and bot registration).

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery

  • Revert the changes to the upload utility module. Only files > 4MB are affected by this change.
  • Watch for: 400 Bad Request on createUploadSession.

Risks and Mitigations

  • Risk: Upload session URL expires after ~24h if an upload stalls.
    • Mitigation: With ~3.1MB chunks, even a 500MB file uploads in seconds on a normal connection. Not a realistic risk.

Greptile Summary

Added support for resumable upload sessions for files > 4MB in MS Teams integration, resolving a hard limitation that caused silent upload failures. The implementation adds a new uploadChunked() helper that creates a Microsoft Graph upload session and uploads files in ~3.1MB chunks (a required multiple of 320 KiB). Both uploadToOneDrive and uploadToSharePoint now auto-detect files > 4MB and use the chunked upload path, while files ≤ 4MB continue using the simple upload endpoint.

Major changes:

  • Added uploadChunked() function for handling resumable upload sessions with proper Content-Range headers
  • Modified uploadToOneDrive to use upload sessions for files > 4MB (lines 91-123)
  • Modified uploadToSharePoint to use upload sessions for files > 4MB (lines 269-301)
  • Added comprehensive unit tests covering both simple and chunked upload paths for OneDrive and SharePoint
  • Implementation correctly uses 320 KiB chunk boundaries as required by Microsoft Graph API

The change is backward compatible and requires no configuration changes. All existing callers work without modification.

Confidence Score: 4/5

  • This PR is safe to merge with low risk
  • The implementation correctly follows Microsoft Graph API specifications for resumable uploads with proper chunk size alignment (320 KiB multiples), Content-Range headers, and error handling. The code is well-tested with unit tests covering both simple and chunked upload paths. The change is backward compatible and self-contained to the MS Teams extension. One minor style improvement was noted regarding unnecessary Math.max() usage, but this does not affect correctness.
  • No files require special attention

Last reviewed commit: 2247f3f

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added channel: msteams Channel integration: msteams size: M labels Feb 20, 2026
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

}

lastResponseData = await res.json();
start = Math.max(start, end);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Math.max(start, end) is unnecessary since end is always >= start

Suggested change
start = Math.max(start, end);
start = end;
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/msteams/src/graph-upload.ts
Line: 60

Comment:
`Math.max(start, end)` is unnecessary since `end` is always >= `start`

```suggestion
    start = end;
```

How can I resolve this? If you propose a fix, please make it concise.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 28, 2026
@openclaw-barnacle openclaw-barnacle bot added the channel: nostr Channel integration: nostr label Feb 28, 2026
@openclaw-barnacle openclaw-barnacle bot removed the stale Marked as stale due to inactivity label Mar 1, 2026
@BradGroux BradGroux self-assigned this Mar 10, 2026
@BradGroux
Copy link
Copy Markdown
Contributor

Hi @krishna-warfade — thanks for the submission. I’m the new Microsoft Teams maintainer for OpenClaw. Please give me a day or two to work through the open Teams backlog. Also, join the Twitter community for daily MS Teams feedback + updates: https://x.com/i/communities/2031170403607974228

1 similar comment
@BradGroux
Copy link
Copy Markdown
Contributor

Hi @krishna-warfade — thanks for the submission. I’m the new Microsoft Teams maintainer for OpenClaw. Please give me a day or two to work through the open Teams backlog. Also, join the Twitter community for daily MS Teams feedback + updates: https://x.com/i/communities/2031170403607974228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: nostr Channel integration: nostr size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants