Skip to content

Commit 4d2b5a0

Browse files
Merge branch 'master' into parker-listing-windows
2 parents 4cb8cc5 + 5a2be16 commit 4d2b5a0

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

packages/core/src/sagemakerunifiedstudio/uriHandlers.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ExtContext } from '../shared/extensions'
99
import { deeplinkConnect } from '../awsService/sagemaker/commands'
1010
import { telemetry } from '../shared/telemetry/telemetry'
1111
import { SmusAuthMode } from '../shared/telemetry/telemetry.gen'
12+
import { getLogger } from '../shared/logger/logger'
1213

1314
const amzHeaders = [
1415
'X-Amz-Security-Token',
@@ -96,6 +97,19 @@ export function register(ctx: ExtContext) {
9697
* @throws Error if required parameters are missing
9798
*/
9899
export function parseConnectParams(query: SearchParams) {
100+
// Extract session from ws_url as fallback. When the deep link URL contains sigv4 params
101+
// embedded inside ws_url with single percent-encoding, VS Code's URI parser can decode
102+
// the %26 separators, causing those params to break out as top-level query params and
103+
// displacing 'session'. The session ID is always present in the ws_url data-channel path.
104+
const wsUrl = query.get('ws_url')
105+
if (!query.has('session') && wsUrl) {
106+
const match = wsUrl.match(/data-channel\/([^?&]+)/)
107+
if (match) {
108+
getLogger().info(`Recovered missing session from ws_url: ${match[1]}`)
109+
query.set('session', match[1])
110+
}
111+
}
112+
99113
const requiredParams = query.getFromKeysOrThrow(
100114
'connection_identifier',
101115
'domain',

packages/core/src/test/sagemakerunifiedstudio/uriHandlers.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ describe('SMUS URI Handler', function () {
111111
assert.strictEqual(resultWithoutOptional.smus_project_id, undefined)
112112
assert.strictEqual(resultWithoutOptional.smus_domain_region, undefined)
113113
})
114+
115+
it('recovers session from ws_url when session param is missing', function () {
116+
const { session: _removed, ...paramsWithoutSession } = validParams
117+
const paramsWithDataChannel = {
118+
...paramsWithoutSession,
119+
ws_url: 'wss://ssmmessages.us-west-2.amazonaws.com/v1/data-channel/SageMaker-remote-abc123?role=publish_subscribe',
120+
}
121+
const query = new SearchParams(paramsWithDataChannel)
122+
const result = parseConnectParams(query)
123+
124+
assert.strictEqual(result.session, 'SageMaker-remote-abc123')
125+
})
114126
})
115127

116128
it('properly encodes cell-number with spaces and special characters', async function () {

0 commit comments

Comments
 (0)