Skip to content

feat(msteams): add OpenClaw User-Agent header to Microsoft HTTP calls#60433

Merged
BradGroux merged 2 commits intoopenclaw:mainfrom
BradGroux:bgod/fix-51568-user-agent-header
Apr 4, 2026
Merged

feat(msteams): add OpenClaw User-Agent header to Microsoft HTTP calls#60433
BradGroux merged 2 commits intoopenclaw:mainfrom
BradGroux:bgod/fix-51568-user-agent-header

Conversation

@BradGroux
Copy link
Copy Markdown
Contributor

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:

  • Added ensureUserAgentHeader() helper in user-agent.ts (respects existing User-Agent if set)
  • Applied to Graph API calls in graph.ts, file uploads in graph-upload.ts, and Bot Framework connector in sdk.ts
  • Added tests across user-agent.test.ts, sdk.test.ts, graph.test.ts, and new file-consent.test.ts

Testing:

  • pnpm test -- extensions/msteams/src/user-agent.test.ts extensions/msteams/src/sdk.test.ts extensions/msteams/src/attachments/graph.test.ts — 20/20 pass
  • pnpm check — clean

Copilot AI review requested due to automatic review settings April 3, 2026 16:58
@openclaw-barnacle openclaw-barnacle bot added channel: msteams Channel integration: msteams size: M maintainer Maintainer-authored PR labels Apr 3, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 3, 2026

Greptile Summary

This PR adds an OpenClaw/<version> User-Agent header to all outbound HTTP requests in the MS Teams extension — Graph API calls, Bot Framework connector initialization, and file consent uploads — via a new ensureUserAgentHeader() helper that wraps buildUserAgent() and preserves any caller-supplied User-Agent. Tests cover the helper directly, all three call sites, and the pass-through behavior.

Confidence Score: 5/5

This PR is safe to merge — all changes are additive and well-tested with no behavioral regressions.

All findings are P2 or lower. The ensureUserAgentHeader helper is a simple, correct wrapper; existing headers are preserved; all three call sites are covered by tests. The only notable observations are (1) file-consent.test.ts runs buildUserAgent() without mocking the runtime but the broad regex accommodates any fallback value, and (2) the pnpm-lock.yaml includes an unrelated extensions/stepfun: {} entry that is a valid workspace importer entry from a rebase.

No files require special attention.

Reviews (1): Last reviewed commit: "feat(msteams): add OpenClaw User-Agent h..." | Re-trigger Greptile

@BradGroux BradGroux self-assigned this Apr 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 generated User-Agent without overwriting an existing one.
  • Added User-Agent headers 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

Comment on lines +79 to +84
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");
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 604 to +608

extensions/speech-core: {}

extensions/stepfun: {}

Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
@BradGroux BradGroux force-pushed the bgod/fix-51568-user-agent-header branch 4 times, most recently from 985d895 to f36734d Compare April 3, 2026 18:40
@BradGroux BradGroux force-pushed the bgod/fix-51568-user-agent-header branch from f36734d to 329d2b0 Compare April 3, 2026 21:48
@BradGroux BradGroux merged commit c88d6d6 into openclaw:main Apr 4, 2026
42 of 80 checks passed
KimGLee pushed a commit to KimGLee/openclaw that referenced this pull request Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: msteams Channel integration: msteams maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

msteams: add OpenClaw User-Agent header to Microsoft backend HTTP calls

2 participants