fix(sdk): Teams adapter — encode channelId, icacls warning, integration tests#883
Conversation
🟡 Impact Analysis — PR #883Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (1 file)
squad-sdk (1 file)
tests (1 file)
This report is generated automatically for every PR. See #733 for details. |
There was a problem hiding this comment.
Pull request overview
This PR delivers three follow-up fixes/improvements to the SDK’s Microsoft Teams communication adapter: safer channel deep-link construction, better Windows permission-hardening observability, and higher-confidence coverage via integration-style tests with mocked Graph API responses.
Changes:
- Encode
channelIdin the Teams channel deep-link URL returned frompostUpdate(). - Log a warning when
icaclsfails during Windows token-file permission hardening. - Add integration tests for adapter class methods (
ensureAuthenticated,ensureChat,postUpdate,pollForReplies) using mockedfetchandnode:fs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
test/comms-teams-integration.test.ts |
Adds integration tests for Teams adapter class methods with mocked Graph API and token persistence. |
packages/squad-sdk/src/platform/comms-teams.ts |
Fixes channel deep-link encoding and surfaces icacls failures via console.warn. |
.changeset/teams-adapter-fixes.md |
Adds a patch changeset entry documenting the Teams adapter fixes and new tests. |
✅ APPROVED (CI/CD Review)SummaryAll CI/CD gates passing. PR meets quality standards for merge. Checklist Results✅ Changeset File: Present (.changeset/teams-adapter-fixes.md)
File Scope
VerdictAPPROVE — Ready to merge from CI/CD perspective. All automation gates satisfied. |
🔒 RETRO Security Review — PR #883Verdict: ✅ APPROVE All three changes are clean from a security perspective. No request for changes. #771 — channelId encodingFinding: Sufficient. The Other parameters? I checked:
No gaps found. The encoding is consistent across all URL-facing parameters. #770 — icacls warning logFinding: Acceptable. The Bonus: Test mock safetyFinding: Clean. All test tokens are obviously fake strings ( Token refresh logicFinding: Sound. Key observations:
Summary: Solid security posture. The — RETRO, Security Specialist |
🔍 Quality Review — FIDO (Quality Owner)Verdict: Approve with changes — production fixes look correct, but test coverage has gaps that weaken the "3 fixes + 10 tests" story. ✅ What's good
|
| Fix | Tests | Covered? |
|---|---|---|
| #771 channelId encoding | Test 3 | ✅ Direct assertion |
| #770 icacls warning | — | ❌ No test exercises error path |
| #772 integration tests | Tests 1-10 | ✅ Good breadth, gaps noted above |
Bottom line
The production code changes are minimal and correct. The test suite is a strong start but oversells coverage — 1 of 3 fixes is untested and the mock isolation has a leak. Addressing findings 1-3 would make this a confident approve.
0035407 to
a51cac0
Compare
|
Addressed all three FIDO review items in a51cac0 (squashed to 1 commit): Fix 1 — \�i.unstubAllGlobals()\ in afterEach: Added to prevent fetch stub leaking between tests. Fix 2 — icacls warning test: New test \logs warning when icacls fails on Windows\ mocks Fix 3 — Token refresh failure test: New test \warns on refresh failure and falls back to device code\ provides an expired cached token, mocks the refresh endpoint to return \invalid_grant\ (no \�ccess_token), and verifies the adapter (a) logs the refresh warning, (b) falls through browser auth (mocked All 47 Teams tests + 52 SDK tests pass. 12 integration tests total (up from 10). |
a51cac0 to
fb3ac33
Compare
|
Why is the comms integration file failing and why is the file name different from the thing it is testing. |
fb3ac33 to
4fb6155
Compare
🔍 Squad Review — Kaylee (Engineering)
Verdict: ✅ Ready to merge Review by Squad AI team (Kaylee — Engineering) · requested by Dina Berry |
diberry
left a comment
There was a problem hiding this comment.
required: The channelId encoding fix is correct (\�ncodeURIComponent\ is right for URL path segments), but the deep-link URL template was already structurally incomplete before this PR — it's missing the /{channelName}?groupId={teamId}&tenantId={tenantId}\ suffix. Encoding a broken template just makes it a correctly-encoded broken URL. Worth tracking as a follow-up issue if not addressing here.
suggestion: Only the icacls failure path (warning emitted) is tested. A complementary test confirming warnSpy is NOT called when execFile succeeds on win32 would guard against a future inversion of the if(err) guard.
suggestion: Test section comment numbering is inconsistent — the comment // ─── 3. postUpdate to chat vs channel\ appears before the icacls section, making it appear unnumbered.
nit: encodeURIComponent coverage is narrow — only tests 19:channel@thread.tacv2. A parameterized case with a space or # would verify the encoding contract more thoroughly, though Teams IDs don't contain these in practice.
|
✅ CI validation passed on fork: diberry#145 — 7/7 checks green |
…on tests (#883) Co-authored-by: Dina Berry <diberry@users.noreply.github.com>
Summary
Combined fix for three Teams adapter issues from PR #768 review follow-ups.
#771 — Encode channelId in Teams deep-link URL
\channelId\ was used unvalidated in the deep-link URL template. Applied \�ncodeURIComponent()\ to match the existing pattern used by \getNotificationUrl()\ for chat IDs.
#770 — Log warning when icacls fails on Windows token permission hardening
The \�xecFile('icacls', ...)\ callback was a no-op — failures were silently swallowed. Now logs a warning: \⚠️ Could not restrict token file permissions: {message}.
#772 — Integration tests for Teams adapter class methods
Added 10 integration tests with mocked Graph API covering:
Test results
\
✓ test/comms-teams.test.ts (35 tests)
✓ test/comms-teams-integration.test.ts (10 tests)
Test Files 2 passed (2)
Tests 45 passed (45)
\\
Closes #772, closes #771, closes #770