feat(msteams): add OpenClaw User-Agent header to Microsoft HTTP calls#60433
Conversation
Greptile SummaryThis PR adds an Confidence Score: 5/5This PR is safe to merge — all changes are additive and well-tested with no behavioral regressions. All findings are P2 or lower. The No files require special attention. Reviews (1): Last reviewed commit: "feat(msteams): add OpenClaw User-Agent h..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR adds an OpenClaw/<version> identifier to outbound Microsoft HTTP requests made by the MS Teams extension (Graph, attachment downloads, uploads, and Bot Framework connector calls) to improve attribution/observability (Fixes #51568).
Changes:
- Added an
ensureUserAgentHeader()helper to apply a generatedUser-Agentwithout overwriting an existing one. - Added
User-Agentheaders to Graph attachment fetches and Graph upload helpers. - Added/expanded Vitest coverage for User-Agent propagation, including new file-consent upload tests.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds a new workspace importer entry (unrelated to User-Agent change). |
| extensions/msteams/src/user-agent.ts | Introduces ensureUserAgentHeader() helper that preserves an existing User-Agent. |
| extensions/msteams/src/user-agent.test.ts | Adds unit coverage for ensureUserAgentHeader(). |
| extensions/msteams/src/sdk.test.ts | Adds assertion that Bot Framework connector client receives the OpenClaw User-Agent. |
| extensions/msteams/src/graph-upload.ts | Adds User-Agent to select Graph upload/helper requests. |
| extensions/msteams/src/graph-upload.test.ts | Extends expectations to assert User-Agent on upload/helper requests. |
| extensions/msteams/src/file-consent.test.ts | New test asserting User-Agent is sent for consent URL uploads. |
| extensions/msteams/src/attachments/graph.ts | Ensures guarded Graph attachment fetches include User-Agent (without overwriting caller-provided UA). |
| extensions/msteams/src/attachments/graph.test.ts | Adds tests asserting guarded Graph fetches and shares downloads include User-Agent. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| it("adds the generated User-Agent to Headers instances without overwriting callers", () => { | ||
| const generated = ensureUserAgentHeader(); | ||
| expect(generated.get("User-Agent")).toMatch(/^teams\.ts\[apps\]\/.+ OpenClaw\/2026\.3\.19$/); | ||
|
|
||
| const custom = ensureUserAgentHeader({ "User-Agent": "custom-agent/2.0" }); | ||
| expect(custom.get("User-Agent")).toBe("custom-agent/2.0"); |
There was a problem hiding this comment.
The new test name says it covers passing a Headers instance, but it only exercises ensureUserAgentHeader() (no args) and a plain object. Consider adding an assertion for ensureUserAgentHeader(new Headers({ ... })) and/or renaming the test. Also, using mockRuntime.version in the regex (instead of hardcoding 2026.3.19) will make the test less brittle if the mocked version changes.
|
|
||
| extensions/speech-core: {} | ||
|
|
||
| extensions/stepfun: {} | ||
|
|
There was a problem hiding this comment.
This lockfile change adds a new workspace importer (extensions/stepfun) but it isn’t mentioned in the PR description and appears unrelated to the User-Agent work. If it’s not intentional/required for CI, consider dropping it to keep the PR focused (or mention why it’s needed).
985d895 to
f36734d
Compare
f36734d to
329d2b0
Compare
…openclaw#51568) (openclaw#60433) Co-authored-by: Brad Groux <[email protected]>
Fixes #51568
Adds an
OpenClaw/<version>User-Agent header to all outbound HTTP calls from the Teams plugin — Graph API, Bot Framework connector, and file uploads.Changes:
ensureUserAgentHeader()helper inuser-agent.ts(respects existing User-Agent if set)graph.ts, file uploads ingraph-upload.ts, and Bot Framework connector insdk.tsuser-agent.test.ts,sdk.test.ts,graph.test.ts, and newfile-consent.test.tsTesting:
pnpm test -- extensions/msteams/src/user-agent.test.ts extensions/msteams/src/sdk.test.ts extensions/msteams/src/attachments/graph.test.ts— 20/20 passpnpm check— clean