Skip to content

fix(msteams): patch Teams HttpPlugin /api* route pattern in dist#54880

Closed
ruanrrn wants to merge 3 commits intoopenclaw:mainfrom
ruanrrn:bughunt/fix-msteams-api-route-regression
Closed

fix(msteams): patch Teams HttpPlugin /api* route pattern in dist#54880
ruanrrn wants to merge 3 commits intoopenclaw:mainfrom
ruanrrn:bughunt/fix-msteams-api-route-regression

Conversation

@ruanrrn
Copy link
Copy Markdown

@ruanrrn ruanrrn commented Mar 26, 2026

Summary

  • Problem: Teams channel crashes on startup after 2026.3.24 with Missing parameter name at index 5: /api*.
  • Why it matters: This is a high-severity regression; Teams channels fail to start and cannot receive messages.
  • What changed: Added a runtime-postbuild patch that rewrites the Teams SDK HttpPlugin Express mount from "/api*" to "/api" in the emitted dist/ bundle.
  • What did NOT change (scope boundary): No Teams runtime behavior changes beyond the route pattern; no config changes; no dependency upgrades.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause / Regression History (if applicable)

  • Root cause: The Teams SDK HttpPlugin registers this.express.use("/api*", express.json()), which is rejected by newer path-to-regexp behavior (commonly encountered via Express v5) with Missing parameter name at index 5: /api*.
  • Missing detection / guardrail: No build-time check to catch invalid Express route patterns emitted from bundled dependencies.
  • Prior context (git blame, prior PR, issue, or refactor if known): Reported in [Bug]: Teams Broken After 2026.3.24 udpates #54703; appears related to the Teams SDK migration (see issue comments).
  • Why this regressed now: 2026.3.24 update changed the runtime dependency graph such that the invalid pattern now triggers at startup.
  • If unknown, what was ruled out: N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: N/A (build artifact patch)
  • Scenario the test should lock in: After scripts/runtime-postbuild.mjs, no emitted dist/*.js should contain this.express.use("/api*", express_1.default.json());.
  • Why this is the smallest reliable guardrail: This regression is in the emitted bundle codepath; a postbuild assertion/patch is the minimal containment.
  • Existing test that already covers this (if any): None
  • If no new test is added, why not: This PR is intentionally minimal and avoids adding a new test harness around build outputs; the patch is deterministic and idempotent.

User-visible / Behavior Changes

  • Teams channels no longer crash on startup due to the invalid /api* Express route pattern.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: Node 22
  • Integration/channel (if any): Microsoft Teams

Steps

  1. Build the project (emits dist/).
  2. Run node scripts/runtime-postbuild.mjs.
  3. Confirm emitted bundle no longer contains the "/api*" route pattern for the Teams SDK HttpPlugin.

Expected

  • Teams channel startup should not throw Missing parameter name at index 5: /api*.

Actual

  • Before: startup crash when the emitted bundle registers "/api*".
  • After: postbuild rewrites "/api*" -> "/api".

Evidence

  • Trace/log snippets

Issue report + workaround confirmation: #54703

Human Verification (required)

  • Verified scenarios:
    • Ran a small node snippet to ensure scripts/patch-msteams-httpplugin-route.mjs rewrites the emitted code as intended.
  • Edge cases checked:
    • Idempotency (no change when already patched).
    • Skips cleanly when dist/ is missing.
  • What you did not verify:
    • Full pnpm build / Teams E2E runtime startup in this environment.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit 09f4445060.
  • Files/config to restore: scripts/runtime-postbuild.mjs, scripts/patch-msteams-httpplugin-route.mjs.
  • Known bad symptoms reviewers should watch for: build postprocess step unexpectedly rewriting unrelated dist files (should be limited to exact needle match).

Risks and Mitigations

  • Risk: Postbuild patch misses future upstream changes if the emitted code string changes.
    • Mitigation: The patch is narrowly targeted; if the needle changes, Teams would regress again and the fix can be adjusted to match the new emitted form.

@openclaw-barnacle openclaw-barnacle bot added scripts Repository scripts size: S labels Mar 26, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR fixes a high-severity Teams channel startup regression by adding a postbuild patch script that rewrites the invalid /api* Express route pattern to /api in the emitted dist/ bundle. The fix is minimal, correctly targeted, and semantically safe. Two non-blocking P2 style issues were identified in scripts/patch-msteams-httpplugin-route.mjs.

Confidence Score: 4/5

Safe to merge; the fix is minimal and correctly targeted.

Both flagged items are P2 style issues that do not affect correctness on the primary Linux build environment.

scripts/patch-msteams-httpplugin-route.mjs

Important Files Changed

Filename Overview
scripts/patch-msteams-httpplugin-route.mjs New patch script; logic is correct and idempotent, two minor style issues identified.
scripts/runtime-postbuild.mjs Minimal, well-placed wiring of the new patch into the existing postbuild pipeline.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: scripts/patch-msteams-httpplugin-route.mjs
Line: 33

Comment:
**Inconsistent entry-point detection — prefer `pathToFileURL`**

Every other standalone script in this project uses `pathToFileURL(process.argv[1] ?? "").href`. On Windows, `new URL("C:\\path\\to\\file.mjs", "file:")` misparses the drive letter as a protocol, while `pathToFileURL` handles Windows paths correctly.

```suggestion
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: scripts/patch-msteams-httpplugin-route.mjs
Line: 30

Comment:
**Silent no-op when needle is absent after a full scan**

When `dist/` exists but no file contains the needle, the function returns `{ changedFiles: [], skipped: null }` with no warning. If the transpiler variable name for `express_1` changes, Teams regresses silently. Consider emitting a `stderr` warning when `changedFiles.length === 0` and `skipped` is null.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(msteams): patch Teams HttpPlugin /ap..." | Re-trigger Greptile

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09f4445060

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ruanrrn ruanrrn force-pushed the bughunt/fix-msteams-api-route-regression branch from 09f4445 to cb2de0a Compare March 26, 2026 04:29
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb2de0a270

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@BradGroux
Copy link
Copy Markdown
Contributor

Superseded by #55440, which has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Teams Broken After 2026.3.24 udpates

2 participants