Skip to content

[#1183] agents-copilotstudio-client: Use segment encoding for URL interpolation - #1194

Open
ceciliaavila wants to merge 2 commits into
mainfrom
southworks/fix/csc-url-handling
Open

[#1183] agents-copilotstudio-client: Use segment encoding for URL interpolation#1194
ceciliaavila wants to merge 2 commits into
mainfrom
southworks/fix/csc-url-handling

Conversation

@ceciliaavila

Copy link
Copy Markdown
Collaborator

Fixes #1183

Description

This pull request improves the handling of URL path segments in the Copilot Studio client by ensuring that both schema and conversationId values are properly URL-encoded wherever they are used to construct URLs. This prevents errors when these values contain reserved or special characters. The changes are verified by new tests covering these encoding scenarios.

URL Encoding Improvements:

  • Updated createURL in powerPlatformEnvironment.ts to encode conversationId when appending it to the URL path.
  • Updated PrebuiltBotStrategy and PublishedBotStrategy to encode schema and conversationId in URL path segments. [1] [2] [3] [4]

Testing Enhancements:

  • Added tests for URL encoding in powerPlatformEnvironment.test.ts, prebuiltBotStrategy.test.ts, and publishedBotStrategy.test.ts to ensure correct URL construction with reserved characters. [1] [2] [3]

Testing

This image shows the copilotstudio-webchat sample working and the encoded conversationId interpolated in the url.
image

Copilot AI review requested due to automatic review settings July 21, 2026 14:39
@ceciliaavila
ceciliaavila requested a review from a team as a code owner July 21, 2026 14:39

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.

Pull request overview

This PR fixes URL path construction in agents-copilotstudio-client by applying URL segment encoding to user-provided values (schema and conversationId) when interpolating them into URL pathnames, preventing malformed URLs when those values contain reserved characters (e.g., /, ?, #).

Changes:

  • Encode schema when building the base bot URL in PrebuiltBotStrategy and PublishedBotStrategy.
  • Encode conversationId when appending it as a /conversations/{id} path segment in strategies and direct-connect URL handling.
  • Add focused unit tests validating correct URL output with reserved characters for direct-connect + both strategies.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/agents-copilotstudio-client/src/powerPlatformEnvironment.ts Encodes conversationId when constructing direct-connect conversation/subscribe URLs.
packages/agents-copilotstudio-client/src/strategies/prebuiltBotStrategy.ts Encodes schema and conversationId when constructing prebuilt agent conversation URLs.
packages/agents-copilotstudio-client/src/strategies/publishedBotStrategy.ts Encodes schema and conversationId when constructing published agent conversation URLs.
packages/agents-copilotstudio-client/test/powerPlatformEnvironment.test.ts Adds coverage for direct-connect conversation/subscribe URL encoding behavior.
packages/agents-copilotstudio-client/test/prebuiltBotStrategy.test.ts Adds coverage for prebuilt strategy URL encoding behavior.
packages/agents-copilotstudio-client/test/publishedBotStrategy.test.ts Adds coverage for published strategy URL encoding behavior.

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.

agents-copilotstudio-client: Use segment encoding for URL interpolation

2 participants