Repository navigation
fix: validate Amazon Q SSO connection command inputs - #241
XiaowenMaoA wants to merge 1 commit into
Conversation
98ea1f5 to
8def5d7
Compare
8def5d7 to
a19e5e8
Compare
dungdong-aws
left a comment
There was a problem hiding this comment.
Requesting changes. Reviewed at a19e5e8, comparing behavior against main (f1ef1f1). I ran the real modules with a small harness for each case below, on both commits.
Blocking
-
Existing connections are rejected instead of reused.
validateIsNewSsoUrlAsyncin the command returns "A connection for this start URL already exists" when a connection to the same host with Amazon Q scopes exists.AuthUtil.connectToEnterpriseSsois built to reuse, add scopes to, or reauthenticate that connection. On this PR, these work on main but fail here:- re-running the command while connected;
- reconnecting an expired connection;
- selecting a customization (
customizationArn/ prefix) while signed in; - connecting to a second
identitycenter.amazonaws.com/ssoins-…instance. The check compares only the host, so a different instance counts as a match.
Suggest dropping that check from the command (the format check is enough) and adding a test with an existing connection plus a
customizationArn. -
The region check in
OidcClient.create()runs for every stored profile.Auth.getSsoTokenProvidercalls it from list, restore, validate, reauthenticate,getSsoAccessTokenand sign-out. A stored profile whose region doesn't match the new pattern (for exampleUS-EAST-1, which main accepted, or a futureap-southeast-10) makesAuth.listConnections()throw for all connections. Signing out of that profile also throws and leaves it stored, and the start URL prompter fails. Please validate the region where a new profile is created, or inauthorize()and on the connect path, rather than in the shared factory. A stored profile that fails validation should still be listable and removable. -
The new modal confirmation breaks programmatic callers. The internal E2E auth suite calls
aws.codeWhisperer.connect(source, startUrl, region)and expects a connection. In the extension test host, VS Code refuses modal dialogs, so the command errors without connecting; if nothing answers the dialog, the command never returns. The E2E suite needs a way to skip the prompt, or the prompt should be handled differently for callers that pass arguments. Please coordinate with the E2E owners before merging.
Non-blocking
ssoRegionFormatRegex(-\d$) rejects two-digit suffixes and uppercase input. Consider-\d+$and normalizing case.- The command now hard-fails URLs that main accepted and the other sign-in paths only warn on. These include the documented
ssoins-….portal.<region>.app.awsandssoins-….<region>.portal.amazonaws.comportal formats, URLs with a trailing#/copied from the browser, uppercase hosts, and custom redirect start URLs. - The
getRegions()check depends on the region provider's state. With only the bundled endpoints it rejects some current regions (e.g.ap-southeast-7), and with an empty provider it rejects everything. - The prompt says "This replaces your current Amazon Q connection" even when there is no connection.
- Tests to add: existing valid/expired connection, dismissed dialog, customization arguments, stored profile with a non-matching region, valid URL variants (alias subdomain, trailing slash, ssoins), and a caller that passes arguments without UI.
- Please use neutral names in the tests (e.g. "rejects malformed region",
example.invalid). Please also edit the earlier PR comment to remove the internal tracking reference.
The checks that reject a path, fragment, userinfo or backslash in the start URL, and a region that changes the host, look good. Calling the command with no arguments behaves the same as before.
Summary
Testing
feature/xbranches will not be squash-merged at release time.