[#1183] agents-copilotstudio-client: Use segment encoding for URL interpolation - #1194
Open
ceciliaavila wants to merge 2 commits into
Open
[#1183] agents-copilotstudio-client: Use segment encoding for URL interpolation#1194ceciliaavila wants to merge 2 commits into
ceciliaavila wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
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
schemawhen building the base bot URL inPrebuiltBotStrategyandPublishedBotStrategy. - Encode
conversationIdwhen 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1183
Description
This pull request improves the handling of URL path segments in the Copilot Studio client by ensuring that both
schemaandconversationIdvalues 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:
createURLinpowerPlatformEnvironment.tsto encodeconversationIdwhen appending it to the URL path.PrebuiltBotStrategyandPublishedBotStrategyto encodeschemaandconversationIdin URL path segments. [1] [2] [3] [4]Testing Enhancements:
powerPlatformEnvironment.test.ts,prebuiltBotStrategy.test.ts, andpublishedBotStrategy.test.tsto 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.
