Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: stale review; fresh review needed. Summary Next step Review history (60 earlier review cycles; latest 8 shown)
|
5efb45c to
54c5a69
Compare
54c5a69 to
5eed940
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
96bd5df to
04c12a8
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
04c12a8 to
ba155fd
Compare
|
@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. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
2379dda to
ce1e925
Compare
|
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. |
|
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
|
Rebased onto current main again. Blank site rejection, regional team lookup, and the private/shared channel guard are unchanged. @clawsweeper please re-review. |
|
Rebased onto current main again. Blank site rejection, regional team lookup, and the private/shared channel guard are unchanged. @clawsweeper please re-review. |
|
@clawsweeper re-review Rebased onto current main. The delivery-authority finding is fixed on this head: A closed handoff does not call |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Rebased onto current main. Both review items on the previous head are fixed:
The earlier production file-card, shared-channel reject, and explicit-site evidence is unchanged. |
|
🦞👀 Re-review progress:
|
|
CI ratchet failures on the previous head are fixed:
No new code findings on revision 43. The remaining review items are a maintainer decision on automatic site discovery plus |
|
Updated at
Remaining items are for maintainers: accepting automatic standard-channel discovery plus @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Rebased onto current main and added the requested proof to the PR body.
|
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Rebased onto current main; the conflict was main inlining the SharePoint upload into |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Rebased onto current main. Main had inlined The previous head's only red check was |
|
🦞👀 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.
|
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! |
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 viawebDavUrl, 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
sharePointSiteIdfor standard channels. Group chats and private/shared channels still require an explicit site. Existing deployments withsharePointSiteIdset are unchanged.New optional Graph permission for automatic discovery:
Channel.ReadBasic.All(so private/shared channels are rejected before parent-team upload). Uploads still needSites.ReadWrite.All.sharePointFolderstays in this change with a strict contract: one folder name, no path separators, URL-encoded. Default remainsOpenClawShared.Why This Change Was Made
When
sharePointSiteIdis omitted, a standard channel's file send resolves the team's backing site withGET /groups/{groupId}/sites/rootand 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.tsandmessenger.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.getByIdlookup intoresolveUploadSiteId→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
membershipTypeis checked first; anything other thanstandardfails closed unless an explicitsharePointSiteIdis set. Group chats still requiresharePointSiteId(no team site).Site discovery uses the abortable request owner so a stalled
/sites/rootfetch is cancelled when the deadline expires. Folder names are validated as a single segment and encoded before interpolation.Evidence
vitestwithtest/vitest/vitest.extension-msteams.config.ts). Cold-start cases insend.test.tsandmessenger.sharepoint-site.test.tsrun the realresolveUploadSiteIdand team lookup; only Graphfetchand the TeamsgetByIdare stubbed, and they assert the site the file was uploaded to. Also covered: stored regionalserviceUrlvs app endpoint (lookup onapp.api.fromServiceUrl(<stored URL>); matching URLs keepapp.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,.,..).extensions/msteams/plussrc/config/types.msteams.ts, generated channel metadata, and Teams docs (messaging, configuration, setup permissions).sharePointSiteIdstill wins and skips membership checks.sharePointFolderdefaults toOpenClawShared. No config migration.Real behavior proof (production, 2026-09-02) — standard channel
Deployed to a production OpenClaw instance serving multiple Microsoft Teams teams.
sharePointSiteIdremoved (key absent, not an empty sentinel).sharePointFolderset 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):
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:
sharePointSiteIdfailed 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.
sharePointSiteIdstill absent (key commented out). Custom single-segmentsharePointFolder. 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):
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)
sharePointSiteIdabsent. A shared channel (not standard) received a file-send request. Gateway log (redacted):No
sent native file cardfollowed. The membership check failed closed before a SharePoint upload.Explicit site still wins (production, 2026-09-22)
The same production instance, with
sharePointSiteIdset again, in a standard channel. Gateway log (redacted):The file card was sent while the explicit site was set. There was no "standard channels only" rejection.
sharePointSiteIdwas removed immediately after.Regional endpoint
send.tsandmessenger.tslook up the team throughresolveReferenceScopedTeamsApi, which reuses the proactive send path'sgetApiClientForReference. When the storedserviceUrldiffers from the app endpoint, lookup runs onapp.api.fromServiceUrl(<stored URL>). When they match, or no stored URL is present, lookup stays onapp.api.Tests use an
emeastored URL with anamerapp endpoint and assertgetByIdruns on the regional client and not onapp.api. A matching-URL case assertsfromServiceUrlis 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-fileParallelismon 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-nodejob budget (timeout-minutes: ${{ matrix.timeout_minutes || 60 }}in.github/workflows/ci.yml).Delivery authority
resolveUploadSiteIdreceives the sameassertDirectAdapterHandoffas 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:
getTeamDetails, token acquisition, and fetch are not called./sites/rootis not requested.Revocation trace (real clients, 2026-10-04)
Diagnostic run at head
fbb5c21on a production gateway host, using its Teams app credentials and a stored standard-channel (General) reference on a regional endpoint. It uses the real SDKApp,createMSTeamsTokenProvider,lookupReferenceScopedTeamDetails, andresolveUploadSiteId, with no mocks.app.tokenProvider.getAppTokenis wrapped, and the handoff closes right after the targeted token resolves.diagnostics_channel(http.client.request.start,undici:request:create).<channel-id>.Revoked during the Bot Framework token, before the Teams lookup. No Teams or Graph request is sent:
Revoked during the Graph token, after the Teams lookup. No Graph request is sent:
Allowed control. Teams lookup, membership check, then the team site:
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/conversationsplugin state: a standard team channel (General) on a regional endpoint. Ids, tenant, and site are redacted.v2026.10.5(official tag),sharePointSiteIdset explicitly to the team's site:openclaw doctor --fix, the standard upgrade step; it is unrelated to this change:sharePointSiteIdremoved (offlineopenclaw config patch), same stored reference:Discovery chose the same site that was configured explicitly in steps 1 and 3.
Control,
v2026.10.5withsharePointSiteIdabsent and the same stored reference:Data-model compatibility
teamIdandserviceUrl, which stored references already carry.sharePointFolderis new and optional (defaultOpenClawShared). An explicitsharePointSiteIdkeeps working as before. A blank explicit value now fails with a specific error instead of the previous "required" error. No migration.Addressed Review Findings
send.tsandmessenger.tspass a reference-scopedgetByIdintoresolveUploadSiteId. Tests run real discovery from a channel file send and assert the team lookup and the uploaded site.resolveReferenceScopedTeamsApi, which reusesgetApiClientForReference. Differing app/stored URLs callgetByIdonapp.api.fromServiceUrl(<stored URL>)..../\\);encodeURIComponenton folder and filename. Tests cover#encoding and rejected paths.sharePointSiteId;Channel.ReadBasic.Alllisted.withMSTeamsAbortableRequestTimeoutand passessignalinto fetch. Test aborts a hanging/sites/rootcall.sharePointSiteIdis set. Explicit site skips the membership check for compatibility.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.