Skip to content

feat(msteams): resolve team SharePoint site dynamically for channel file uploads - #136274

Closed
a-tokyo wants to merge 3 commits into
openclaw:mainfrom
a-tokyo:feature/per-team-sharepoint-upload
Closed

a-tokyo wants to merge 3 commits into
openclaw:mainfrom
a-tokyo:feature/per-team-sharepoint-upload

Conversation

@a-tokyo

@a-tokyo a-tokyo commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #136271

What Problem This Solves

Fixes: Teams channel members see "request access" when opening files the bot sent. The bot uploaded every file to one configured SharePoint site (sharePointSiteId). The native file card links via webDavUrl, which requires membership of that site — not membership of the Teams team.

In multi-team deployments this is a production failure: members of a team can read the channel message but cannot open the attached file unless they also have access to the bot's central SharePoint site.

User Impact

User impact: members of a standard Teams channel can open files the bot sends, because those files land on that team's own SharePoint site. Operators can omit sharePointSiteId for standard channels. Group chats and private/shared channels still require an explicit site. Existing deployments with sharePointSiteId set are unchanged.

New optional Graph permission for automatic discovery: Channel.ReadBasic.All (so private/shared channels are rejected before parent-team upload). Uploads still need Sites.ReadWrite.All.

sharePointFolder stays in this change with a strict contract: one folder name, no path separators, URL-encoded. Default remains OpenClawShared.

Why This Change Was Made

When sharePointSiteId is omitted, a standard channel's file send resolves the team's backing site with GET /groups/{groupId}/sites/root and uploads there. Team membership already grants read access on that site, so the file card works.

Resolution is lazy at the upload boundary in send.ts and messenger.ts. Text-only messages never call Graph for a site ID.

Cold-start after restart: both upload entry points pass the Teams SDK app.api.teams.getById lookup into resolveUploadSiteId → resolveTeamGroupId, so a stored conversation can still resolve the AAD group when the process cache is empty.

Private and shared channels are not auto-discovered. Graph membershipType is checked first; anything other than standard fails closed unless an explicit sharePointSiteId is set. Group chats still require sharePointSiteId (no team site).

Site discovery uses the abortable request owner so a stalled /sites/root fetch is cancelled when the deadline expires. Folder names are validated as a single segment and encoded before interpolation.

Evidence

  • Focused tests: 93 files, 921/921 msteams tests passed (vitest with test/vitest/vitest.extension-msteams.config.ts). Cold-start cases in send.test.ts and messenger.sharepoint-site.test.ts run the real resolveUploadSiteId and team lookup; only Graph fetch and the Teams getById are stubbed, and they assert the site the file was uploaded to. Also covered: stored regional serviceUrl vs app endpoint (lookup on app.api.fromServiceUrl(<stored URL>); matching URLs keep app.api); private-channel reject before /sites/root; explicit-site short-circuit (no membership lookup); stalled discovery abort; folder encoding (Reports#2026 → Reports%232026); folder rejection (../secrets, a/b, a\\b, ., ..).
  • Static proof: pre-commit oxfmt + oxlint on changed files, zero findings.
  • Scope: production changes in extensions/msteams/ plus src/config/types.msteams.ts, generated channel metadata, and Teams docs (messaging, configuration, setup permissions).
  • Backward-compatible: explicit sharePointSiteId still wins and skips membership checks. sharePointFolder defaults to OpenClawShared. No config migration.

Real behavior proof (production, 2026-09-02) — standard channel

Deployed to a production OpenClaw instance serving multiple Microsoft Teams teams. sharePointSiteId removed (key absent, not an empty sentinel). sharePointFolder set to a custom single-segment name.

Before: all uploads went to a private admin-only SharePoint site. A non-admin team member saw "request access" on the file card.

After: the bot wrote and sent a summary as a text file in a standard team channel. Gateway log (redacted):

[msteams] received message — text: "write a one-paragraph summary of …"
         conversation: 19:<channel-id>@thread.tacv2;messageid=<id>
[msteams] dispatching to agent — sessionKey: agent:main:msteams:channel:19:<channel-id>…
[msteams:send] sent native file card — conversationId: 19:<channel-id>@thread.tacv2
         fileName: <summary>.txt

No upload errors. The file card opened with no "request access" prompt. The file landed on the team's own SharePoint site.

Controls from that run:

  • Text-only messages before and after the file send completed without Graph site lookup.
  • First file send resolved the team site (one Graph call); later sends used the cache.
  • An empty env-var sentinel for sharePointSiteId failed closed (400) — empty is not treated as "unset".

Real behavior proof (production, 2026-09-16) — cold-start + ongoing file sends

Same production instance, after a gateway restart onto this revision. sharePointSiteId still absent (key commented out). Custom single-segment sharePointFolder. Gateway became ready at 17:38:27Z; first file send in this window was 18:28:00Z on the same process (empty site cache).

Standard team channel, two inbound turns, three native file cards. Gateway log (redacted):

18:21:57Z [msteams] received message — text: "can you pull …"
          conversation: 19:<channel-id>@thread.tacv2;messageid=<id>
18:21:57Z [msteams] dispatching to agent — sessionKey: agent:main:msteams:channel:19:<channel-id>…:thread:<id>
18:28:00Z [msteams:send] sent native file card — conversationId: 19:<channel-id>@thread.tacv2
          fileName: <report>.csv

19:07:12Z [msteams] received message — text: "can you also pull these by regions?"
          conversation: 19:<channel-id>@thread.tacv2;messageid=<id>
19:07:13Z [msteams] dispatching to agent
19:13:23Z [msteams:send] sent native file card — fileName: <report>_by_region.csv
19:13:25Z [msteams:send] sent native file card — fileName: <report>_region_summary.csv

No SharePoint upload errors. Team members opened the file cards with no "request access" prompt. Files continue to land on that team's own SharePoint site under the configured folder. This is now routine production traffic, not a one-off canary.

Shared channel rejected before upload (production, 2026-09-22)

sharePointSiteId absent. A shared channel (not standard) received a file-send request. Gateway log (redacted):

09:12:01Z [msteams] received message
          conversation: 19:<channel-id>@thread.tacv2;messageid=<id>
09:12:02Z [msteams] dispatching to agent
09:12:29Z [tools] message failed: msteams file send failed: Automatic SharePoint site discovery supports standard channels only. Set channels.msteams.sharePointSiteId to upload to a specific site.
09:12:38Z same failure on a second upload attempt

No sent native file card followed. The membership check failed closed before a SharePoint upload.

Explicit site still wins (production, 2026-09-22)

The same production instance, with sharePointSiteId set again, in a standard channel. Gateway log (redacted):

09:31:56Z config hot reload applied (channels.msteams.sharePointSiteId)
09:32:59Z [msteams] received message
          conversation: 19:<channel-id>@thread.tacv2;messageid=<id>
09:33:00Z [msteams] dispatching to agent
09:33:14Z [msteams:send] sent native file card — fileName: <summary>.txt
09:35:39Z config hot reload applied (channels.msteams.sharePointSiteId removed)

The file card was sent while the explicit site was set. There was no "standard channels only" rejection. sharePointSiteId was removed immediately after.

Regional endpoint

send.ts and messenger.ts look up the team through resolveReferenceScopedTeamsApi, which reuses the proactive send path's getApiClientForReference. When the stored serviceUrl differs from the app endpoint, lookup runs on app.api.fromServiceUrl(<stored URL>). When they match, or no stored URL is present, lookup stays on app.api.

Tests use an emea stored URL with an amer app endpoint and assert getById runs on the regional client and not on app.api. A matching-URL case asserts fromServiceUrl is not called.

Test timing

Single-worker wall time, local, 2026-10-20. Command: vitest run --config test/vitest/vitest.extension-msteams.config.ts --maxWorkers=1 --no-fileParallelism on the changed test files: graph-upload.test.ts, graph-upload.discovery.test.ts, messenger.sharepoint-site.test.ts, messenger.test.ts, send.test.ts.

5 files, 82 tests, all passed. Wall time 57.90s, inside the checks-node job budget (timeout-minutes: ${{ matrix.timeout_minutes || 60 }} in .github/workflows/ci.yml).

Delivery authority

resolveUploadSiteId receives the same assertDirectAdapterHandoff as the upload. A closed handoff is checked before the Teams lookup and before each Graph discovery request.

The Teams lookup itself runs inside an assertion-only Connector handoff, and the handoff is checked again immediately before getById. That handoff does not include dispatch, so a metadata lookup is not treated as a sent message.

Tests:

  • Closed before discovery: getTeamDetails, token acquisition, and fetch are not called.
  • Closed when team lookup returns: no Graph fetch follows.
  • Closed after the membership response: /sites/root is not requested.

Revocation trace (real clients, 2026-10-04)

Diagnostic run at head fbb5c21 on a production gateway host, using its Teams app credentials and a stored standard-channel (General) reference on a regional endpoint. It uses the real SDK App, createMSTeamsTokenProvider, lookupReferenceScopedTeamDetails, and resolveUploadSiteId, with no mocks.

  • Revocation happens inside async token preparation. app.tokenProvider.getAppToken is wrapped, and the handoff closes right after the targeted token resolves.
  • Outbound requests are logged from diagnostics_channel (http.client.request.start, undici:request:create).
  • Each case runs in a fresh process, so team and site caches start empty.
  • Tenant, team, channel, group, and site ids are redacted. A General channel's id equals its team id, so the Bot Framework path shows <channel-id>.

Revoked during the Bot Framework token, before the Teams lookup. No Teams or Graph request is sent:

+  125ms token prepare start: botframework
+  138ms net -> POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
+  302ms token prepare done: botframework
+  302ms handoff revoked (inside async token preparation)
+  304ms result: PlatformMessageNotDispatchedError: delivery authority revoked

Revoked during the Graph token, after the Teams lookup. No Graph request is sent:

+  124ms token prepare start: botframework
+  136ms net -> POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
+  277ms token prepare done: botframework
+  287ms net -> GET https://smba.trafficmanager.net/uk/<tenant-id>/v3/teams/<channel-id>
+  727ms token prepare start: graph
+  729ms net -> POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
+  799ms token prepare done: graph
+  799ms handoff revoked (inside async token preparation)
+  799ms result: PlatformMessageNotDispatchedError: delivery authority revoked

Allowed control. Teams lookup, membership check, then the team site:

+  125ms token prepare start: botframework
+  138ms net -> POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
+  264ms token prepare done: botframework
+  275ms net -> GET https://smba.trafficmanager.net/uk/<tenant-id>/v3/teams/<channel-id>
+  694ms token prepare start: graph
+  696ms net -> POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
+  777ms token prepare done: graph
+  858ms net -> GET https://graph.microsoft.com/v1.0/teams/<guid>/channels/<channel-id>
+ 1537ms token prepare start: graph
+ 1538ms token prepare done: graph
+ 1543ms net -> GET https://graph.microsoft.com/v1.0/groups/<guid>/sites/root
+ 1625ms result: resolved site <site-id>

Upgrade from v2026.10.5 (real gateway, 2026-10-20)

Isolated container on a production gateway host, using its Teams app credentials. No inbound port; cron, Gmail watcher, canvas host, and browser control disabled. Fresh state directory seeded with one stored conversation reference copied byte-for-byte from a production gateway's msteams/conversations plugin state: a standard team channel (General) on a regional endpoint. Ids, tenant, and site are redacted.

  1. v2026.10.5 (official tag), sharePointSiteId set explicitly to the team's site:
$ openclaw --version
OpenClaw 2026.10.5
config sha256 43ca6b7e07e8f5a1
msteams conversation rows: 1; set sha256: 8e0b9d5b492eb26b
$ openclaw message send --channel msteams --target conversation:19:<channel-id>@thread.tacv2 --media upgrade-check-1.txt --json
"deliveryStatus": "sent"
OpenClawShared on the team site: 05:46:18Z upgrade-check-1.txt
  1. Stop the gateway. Start this PR's build on the same state directory. The core agent database (schema v25) asks for openclaw doctor --fix, the standard upgrade step; it is unrelated to this change:
$ openclaw doctor --fix --non-interactive
Updated config: ~/.openclaw/openclaw.json   (adds skills.entries.* toggles and meta.lastTouchedVersion; channels.msteams unchanged)
msteams conversation rows: 1; set sha256: 8e0b9d5b492eb26b
$ openclaw config get channels.msteams --json
{ "enabled": true, "appId": "<redacted>", "appPassword": "<redacted>", "tenantId": "<redacted>",
  "dmPolicy": "disabled", "groupPolicy": "open", "sharePointSiteId": "<site-id>" }
[msteams] starting provider account default (Gateway route /api/messages)
  1. This PR, explicit site still set (existing settings preserved):
$ openclaw message send ... --media upgrade-check-2.txt --json
"deliveryStatus": "sent"
OpenClawShared on the team site: 05:52:09Z upgrade-check-2.txt
  1. This PR, sharePointSiteId removed (offline openclaw config patch), same stored reference:
$ openclaw message send ... --media upgrade-check-4.txt --json
"deliveryStatus": "sent"
OpenClawShared on the team site: 05:54:21Z upgrade-check-4.txt
msteams conversation rows: 1; set sha256: 8e0b9d5b492eb26b

Discovery chose the same site that was configured explicitly in steps 1 and 3.

Control, v2026.10.5 with sharePointSiteId absent and the same stored reference:

"deliveryStatus": "failed",
"error": "msteams file send failed: channels.msteams.sharePointSiteId is required to send files to group chats or channels"

Data-model compatibility

  • No persisted data changes. Conversation references and plugin state keep their existing shape; the team-site cache is in memory only; this PR reads teamId and serviceUrl, which stored references already carry.
  • The upgrade run above shows a reference written by an earlier release loads unchanged (identical row hash before, during, and after) and drives both explicit-site and discovered-site sends.
  • Config: sharePointFolder is new and optional (default OpenClawShared). An explicit sharePointSiteId keeps working as before. A blank explicit value now fails with a specific error instead of the previous "required" error. No migration.

Addressed Review Findings

Finding Resolution
[P1] Pass the Teams lookup into proactive site resolution send.ts and messenger.ts pass a reference-scoped getById into resolveUploadSiteId. Tests run real discovery from a channel file send and assert the team lookup and the uploaded site.
[P2] Scope team-detail lookup to the stored regional endpoint Both callbacks use resolveReferenceScopedTeamsApi, which reuses getApiClientForReference. Differing app/stored URLs call getById on app.api.fromServiceUrl(<stored URL>).
[P2] Encode and constrain the configured folder segment Folder must be a single segment (reject . .. / \\); encodeURIComponent on folder and filename. Tests cover # encoding and rejected paths.
[P2] Document automatic resolution as channel-only Schema, types, messaging, configuration, and manifest-and-permissions docs: standard channels auto-resolve; group chats and private/shared still need sharePointSiteId; Channel.ReadBasic.All listed.
[P2] Abort site discovery when its deadline expires Discovery uses withMSTeamsAbortableRequestTimeout and passes signal into fetch. Test aborts a hanging /sites/root call.
Security: parent-team storage may exceed the channel audience Automatic discovery supports standard channels only. Private/shared fail closed unless sharePointSiteId is set. Explicit site skips the membership check for compatibility.
Folder setting scope Retained: default OpenClawShared, optional override, now with a validated single-segment contract.

AI Assistance

AI-assisted implementation and review. Traced through proactive send, messenger buildActivity, and Graph upload. Validated with the msteams extension test suite and production standard-channel file sends after a gateway restart.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: msteams Channel integration: msteams gateway Gateway runtime size: XL labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head dbb2c552294f1ae57a3121491ac3f175098cf97b, but the PR head is now 8850a0c83e5169794d88775fa983d764a354d51f. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (60 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-06T21:35:34.027Z sha 1b0fde42bd9c2a0380fe53f7e0c5d430bd2cbf0e :: blocked before merge. :: none
  • reviewed 2026-10-07T20:57:08.511Z sha a9215c4c403f7953fb1a8e3577c3f167316a99ee :: blocked before merge. :: none
  • reviewed 2026-10-12T09:27:59.518Z sha 278fd4bc5674d9011eb627d92bf15a75dea3723d :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-14T05:59:08.899Z sha 877eec89d1e1bf9b65f62bbb7cda5406c67cdfdb :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-14T06:10:07.119Z sha 6fc12e507ab67df57a5f497d196e36b04ceef0b3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-20T06:06:11.381Z sha 96b8e209b846c2afa860065fa2c4daf4e1ec864a :: blocked before merge. :: none
  • reviewed 2026-10-21T22:05:11.020Z sha 3fcd5ee1cf512ea60f7b6d1c6532564970f8f867 :: blocked before merge. :: none
  • reviewed 2026-10-22T17:54:24.969Z sha dbb2c552294f1ae57a3121491ac3f175098cf97b :: blocked before merge. :: none

@a-tokyo
a-tokyo force-pushed the feature/per-team-sharepoint-upload branch from 5efb45c to 54c5a69 Compare September 2, 2026 11:44
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed docs Improvements or additions to documentation gateway Gateway runtime size: XL labels Sep 2, 2026
@a-tokyo
a-tokyo force-pushed the feature/per-team-sharepoint-upload branch from 54c5a69 to 5eed940 Compare September 2, 2026 11:52
@a-tokyo

a-tokyo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Sep 2, 2026
@a-tokyo
a-tokyo force-pushed the feature/per-team-sharepoint-upload branch from 96bd5df to 04c12a8 Compare September 2, 2026 12:09
@a-tokyo

a-tokyo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 2, 2026
@a-tokyo
a-tokyo force-pushed the feature/per-team-sharepoint-upload branch from 04c12a8 to ba155fd Compare September 2, 2026 12:28
@a-tokyo

a-tokyo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

All three P1 findings addressed (lazy upload-boundary resolution, cold-start getTeamDetails, session series removed). Real behavior proof added: production deployment across 4 Teams teams, file uploaded to the team's own SharePoint site via dynamic resolution, opened successfully by a team member — no "request access" prompt.

@clawsweeper

clawsweeper Bot commented Sep 2, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@a-tokyo
a-tokyo force-pushed the feature/per-team-sharepoint-upload branch from 2379dda to ce1e925 Compare September 25, 2026 13:29
@a-tokyo

a-tokyo commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and resolved the channel metadata conflict. Blank site rejection, regional team lookup, and the private/shared channel guard are unchanged. @clawsweeper please re-review.

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 25, 2026
@a-tokyo

a-tokyo commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main again. Blank site rejection, regional team lookup, and the private/shared channel guard are unchanged. @clawsweeper please re-review.

2 similar comments
@a-tokyo

a-tokyo commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main again. Blank site rejection, regional team lookup, and the private/shared channel guard are unchanged. @clawsweeper please re-review.

@a-tokyo

a-tokyo commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main again. Blank site rejection, regional team lookup, and the private/shared channel guard are unchanged. @clawsweeper please re-review.

@a-tokyo

a-tokyo commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main. The delivery-authority finding is fixed on this head: resolveUploadSiteId takes assertDirectAdapterHandoff from both send paths and checks it immediately before the Teams lookup and before each Graph discovery request.

A closed handoff does not call getTeamDetails, does not acquire a Graph token, and does not fetch. If it closes after team lookup, no Graph request follows. If it closes after the membership response, /sites/root is not requested. Those three cases are in graph-upload.test.ts. The earlier production file-card, shared-channel reject, and explicit-site evidence is unchanged in the PR body.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@a-tokyo

a-tokyo commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main. Both review items on the previous head are fixed:

  • Team lookup now runs inside an assertion-only Connector handoff and checks authority again after client preparation, before getById. A handoff that closes during that wait does not call getById. The same helper is used from both send paths. Dispatch is not marked for this metadata lookup.
  • appId is removed from the new messenger SharePoint tests. The retry case now expects the current 250ms/500ms delays.

The earlier production file-card, shared-channel reject, and explicit-site evidence is unchanged.

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@a-tokyo

a-tokyo commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

CI ratchet failures on the previous head are fixed:

  • Site-discovery tests moved to graph-upload.discovery.test.ts so graph-upload.test.ts stays within the 1000-line cap.
  • The structural API client cast in sdk-proactive.ts now has a SAFETY comment, back within the assertion baseline.

No new code findings on revision 43. The remaining review items are a maintainer decision on automatic site discovery plus sharePointFolder, and a real-transport revocation trace. The unit tests cover that revocation with mocked clients; there is no production log of a send revoked mid-lookup.

@a-tokyo

a-tokyo commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Updated at fbb5c21:

  • CI: the send.test.ts runtime mock now spreads the real module, and the two stale baseline entries were pruned. The mock-exports ratchet passes.
  • Simplified: site discovery no longer adds handoff checks that requestSharePointJson already runs before token acquisition and before each request. The structural API client cast is gone.
  • Proof: real-client revocation traces are in the PR body under "Revocation trace (real clients, 2026-10-04)". Revoking during either token preparation stops the next Teams or Graph request. The allowed control resolves the site.

Remaining items are for maintainers: accepting automatic standard-channel discovery plus sharePointFolder, and config-compatibility sign-off.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@a-tokyo

a-tokyo commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main and added the requested proof to the PR body.

  • Upgrade from v2026.10.5: real gateway, same state directory, stored channel reference written by an earlier release. Stable sends with an explicit site. After the upgrade, this PR sends with the explicit site unchanged, then discovers the same team site once sharePointSiteId is removed. Row hash is identical throughout. Control: v2026.10.5 without a site fails with "sharePointSiteId is required".
  • Data-model compatibility: no persisted data changes; sharePointFolder is optional; no migration.
  • Tests: the cold-start cases in send.test.ts and messenger.sharepoint-site.test.ts now run the real discovery and team lookup, stub only Graph fetch and getById, and assert the uploaded site. The duplicated retry test is gone.
  • Rebase: main made the Teams client helper synchronous, so the regional team lookup now uses app.api.fromServiceUrl through the same helper.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@a-tokyo

a-tokyo commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main; the conflict was main inlining the SharePoint upload into uploadAndShareSharePoint, so the folder segment now applies there. Removed the two duplicate tests from the last review: the no-team/no-site rejection in graph-upload.discovery.test.ts and the separate default-folder case in graph-upload.test.ts. The previous head's CI was green (72 passed, 0 failed).

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@a-tokyo

a-tokyo commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main. Main had inlined buildActivity into sendMSTeamsMessages and mergeReferenceIntoActivity into the proactive send; site discovery, the team lookup, and sharePointFolder are now applied inside those inlined paths. send.test.ts follows main's mocks: the drive-item lookup and file card run for real against the stubbed Graph fetch.

The previous head's only red check was checks-ui-e2e (1/2): two ui/src/e2e/boot-module-boundaries.e2e.test.ts cases timed out waiting for the Control UI gateway-status "Retry now" button. This PR changes no ui/ code; that shard re-runs on this head.

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Discover a standard channel's team site when sharePointSiteId is omitted, keep
explicit sites authoritative, reject private/shared channels before upload, look
up teams on the stored regional endpoint, carry delivery authority through
discovery, and add an optional single-segment sharePointFolder.
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @a-tokyo for identifying this and for the detailed Teams upload evidence. The focused replacement landed in #189339 as 298b86c, with your co-author credit preserved.

It resolves standard-channel uploads to the team's actual SharePoint site using the existing permission baseline, with bounded caching and regression coverage through both send paths. Closing this in favor of the merged replacement; thank you for the contribution!

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 P2 Normal backlog priority with limited blast radius. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: msteams: resolve team SharePoint site dynamically for channel file uploads

2 participants