Skip to content

fix: update connect URL to target correct geo - #676

Merged
Lily Du (lilyydu) merged 11 commits into
mainfrom
lilyydu/update-connect-endpt
Nov 10, 2026
Merged

Lily Du (lilyydu) merged 11 commits into
mainfrom
lilyydu/update-connect-endpt

Conversation

@lilyydu

@lilyydu Lily Du (lilyydu) commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

related issue: microsoft/teams.ts#985

Summary

  • Route Socket Mode negotiation through https://{geo}.botapi.skype.com/v3/websockets/connect.
  • Remove configurable negotiate base URLs.
  • Default empty geo configurations to amer, emea, and apac.
  • Accept custom non-empty geo values while rejecting empty strings and duplicates.
  • Add secret-safe request URL diagnostics.
  • Update Socket Mode tests and documentation.

Validation

  • Ruff and Pyright pass.
  • 118 Socket Mode tests pass.
  • Live validation reached ready for amer, emea, and apac.

Copilot AI max review requested due to automatic review settings November 9, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unvalidated geo values can redirect negotiation to an attacker-controlled host, exposing the bot's bearer token.

3 open issues
What changed in this PR

Updates Python Socket Mode negotiation to use regional hosts, addressing the missed cross-region activities described in teams.ts#985.

Changes:

  • Replace geo path segments with geo-prefixed service hosts.
  • Add DEBUG logging for resolved negotiation URLs.
  • Update Socket Mode URL assertions, HTTP mocks, and log capture.
File Description
packages/​apps/​tests/​test_socket_mode_transport.py Checks regional URLs and diagnostic logs; updates geo extraction and log capture.
packages/​apps/​tests/​test_socket_mode_connection.py Allows geo-prefixed custom hosts in HTTP mocks.
packages/​apps/​tests/​test_socket_mode_adapter.py Updates URL expectations for default and custom service hosts.
packages/​apps/​src/​microsoft_teams/​apps/​socket_mode/​transport.py Builds geo-specific negotiation URLs and logs each resolved endpoint.

Review effort: Max

@aroy-ms Arup Roy (aroy-ms) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving with some suggestions, let's make sure we're not logging username:pwd if that's in the negotiate url (per the copilot comments)

Copilot AI max review requested due to automatic review settings November 9, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Tests no longer verify first-geo selection and lack direct coverage of invalid-geo rejection and base-path/query preservation in URL construction.

3 open issues
3 resolved since last review

Review effort: Max

Add tests for negotiate_url in SocketModeAdapter.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI max review requested due to automatic review settings November 9, 2026 20:25
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Negotiation URL handling can alter query values and leave the transport reporting CONNECTING with accepting enabled after startup fails on a malformed URL.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Malformed negotiate URL leaves transport stuck connecting

packages/​apps/​src/​microsoft_teams/​apps/​socket_mode/​transport.py:204

If negotiate_base_url is malformed (for example, https://[botapi.example), urlsplit() raises after the transport has entered CONNECTING. Startup then fails with no sockets, but status still reports CONNECTING and accepting remains true. Resolve all negotiate URLs before changing the stop event or lifecycle.

Medium severity Trimming the base URL corrupts query parameters

packages/​apps/​src/​microsoft_teams/​apps/​socket_mode/​transport.py:355

For a custom base URL ending in a query value such as https://botapi.example/ring?route=/, trimming the entire URL before parsing changes the query from route=/ to route=. The negotiate request therefore receives a different parameter value despite the intended query preservation. Parse base_url directly and trim only parsed.path, which is already handled below.

3 resolved since last review

Review effort: Max

Copilot AI max review requested due to automatic review settings November 9, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Mocked tests cannot verify live Teams DNS, routing, and token acceptance for the new Socket Mode hosts, and the change also narrows supported geos and negotiate_base_url values.

No open issues 🎉

Review effort: Max

Copilot AI max review requested due to automatic review settings November 9, 2026 22:28
teddyam

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The implementation and tests use a different regional hostname than the PR summary, leaving unclear whether live verification covered the endpoint being shipped.

1 open issue

Review effort: Max

Copilot AI max review requested due to automatic review settings November 9, 2026 23:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed to evaluate the compatibility impact of removing negotiate_base_url, which breaks existing callers and removes the documented backend-ring selection mechanism.

No open issues 🎉

1 resolved since last review

Review effort: Max

Copilot AI max review requested due to automatic review settings November 9, 2026 23:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Custom geo values remain unvalidated, allowing negotiation requests to expose the bot’s bearer token to an attacker-controlled host.

1 open issue

Review effort: Max

Copilot AI max review requested due to automatic review settings November 10, 2026 00:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because geo-validation edge cases can cause negotiation failures or duplicate connections to the same region.

No open issues 🎉

1 resolved since last review

Review effort: Max

@aroy-ms Arup Roy (aroy-ms) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

approving latest iter

Copilot AI max review requested due to automatic review settings November 10, 2026 02:02
@lilyydu
Lily Du (lilyydu) merged commit 5935996 into main Nov 10, 2026
9 checks passed
@lilyydu
Lily Du (lilyydu) deleted the lilyydu/update-connect-endpt branch November 10, 2026 02:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

A moderate-severity geo-validation regression was omitted from the published review and needs human assessment of its compatibility impact.

No open issues 🎉

Review effort: Max

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants