Skip to content

feat(sagemaker): Added the validation for refresh url and updated the uri handler#8806

Open
msgupta-amazon wants to merge 1 commit into
aws:masterfrom
msgupta-amazon:refreshUrl-validation
Open

feat(sagemaker): Added the validation for refresh url and updated the uri handler#8806
msgupta-amazon wants to merge 1 commit into
aws:masterfrom
msgupta-amazon:refreshUrl-validation

Conversation

@msgupta-amazon

@msgupta-amazon msgupta-amazon commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

##Problem

When Cursor (cursor://) or Kiro (kiro://) handle deep link URIs, their OS protocol handlers percent-encode the query string delimiters before delivering the URI to the extension:

  • = becomes %3D
  • & becomes %26

This causes URLSearchParams to see the entire query as a single malformed parameter, so fields like refreshUrl, sessionId, and streamUrl cannot be parsed. As a result, reconnection never works for Cursor/Kiro — the refreshUrl is lost and the toolkit cannot trigger browser-based session refresh.
VS Code does not exhibit this behavior — it preserves real delimiters in the query string.

##Solution

After the existing + → %2B and & → & normalizations, decode %3D → = and %26 → & in the query string (only after the ?, not in the path) before constructing the URL object.
This is a no-op for VS Code (which never has %3D/%26 as encoded delimiters in the query), so existing Studio and HyperPod VS Code flows are unaffected.

##Testing

  • Verified VS Code deep links still parse correctly (no %3D/%26 in query from VS Code)
  • Verified Cursor/Kiro deep links now parse all params including refreshUrl
  • Reconnection flow tested end-to-end with Cursor

Note: This PR is a follow up of the main PR: #8779
Hence, it will not include changelog entry.


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@msgupta-amazon msgupta-amazon requested a review from a team June 12, 2026 19:26
@amazon-inspector-ohio

Copy link
Copy Markdown

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

@github-actions

Copy link
Copy Markdown
  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@amazon-inspector-ohio

Copy link
Copy Markdown

✅ I finished the code review, and didn't find any security or code quality issues.

function isValidReconnectUrl(refreshUrl: string): boolean {
try {
const parsed = new URL(refreshUrl)
if (parsed.protocol === 'http:') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can we add a comment for when this happens? is this for deeplink from cluster?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, this basically checks the refresh url sent by the MFE

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This check is for local debugging.

return parsed.hostname === 'localhost' || parsed.hostname === '127.0.0.1'
}
if (parsed.protocol === 'https:') {
return parsed.hostname.endsWith('.sagemaker.aws') || parsed.hostname.endsWith('.asfiovnxocqpcry.com')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

whats asfiovnxocqpcry.com ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the demo domain name used in the package for test cases.

}
}

function isValidReconnectUrl(refreshUrl: string): boolean {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FYI if it makes things easier- we can always move the validation to a seperate PR. i'd recommend it since it's a totally separate change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the separate PR right for the validation.

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.

3 participants