Skip to content

Comments

fix(lambda): add confirmation prompt before initiating console login#8598

Open
keenwilson wants to merge 5 commits intoaws:masterfrom
keenwilson:fix/ask-before-fallback-console-login
Open

fix(lambda): add confirmation prompt before initiating console login#8598
keenwilson wants to merge 5 commits intoaws:masterfrom
keenwilson:fix/ask-before-fallback-console-login

Conversation

@keenwilson
Copy link
Contributor

Problem

When users click “Open in VS Code” from the Lambda console and the request reaches Toolkit without an active connection or with mismatched credentials, Toolkit currently falls back to console credential login (aws login) immediately. This triggers a browser-based authentication flow without prior notice.

Solution

This change adds a modal confirmation dialog before invoking aws login in these cases. The dialog explains that Toolkit will sign in using browser-based authentication and states the required prerequisites. Users must explicitly choose to continue before the console login flow starts.

The prompt:

  • Explains that signing in is required to open the Lambda function locally
  • Informs users that browser-based authentication will occur
  • States the AWS CLI and permission prerequisites
  • Allows users to explicitly choose whether to proceed

This makes the flow intentional, reduces surprise browser redirects, and helps distinguish between informed cancellation and setup issues.

Screenshots

Screenshot 2026-02-23 at 3 53 57 PM
  • 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.

@keenwilson keenwilson requested a review from a team as a code owner February 24, 2026 00:36
@amazon-inspector-ohio
Copy link

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

@amazon-inspector-ohio
Copy link

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

})
}

export async function promptConsoleLogin(functionName: string): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

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

is functionName being used in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for catching this. This param is not used. I will remove it.

return false
}

return response === continueBtn
Copy link
Contributor

Choose a reason for hiding this comment

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

are we handling here what happens if user closes the modal?

Copy link
Contributor Author

@keenwilson keenwilson Feb 24, 2026

Choose a reason for hiding this comment

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

If user "cancel" the modal, users will see "Failed to handle URI" and logs like:

2026-02-23 17:08:26.788 [error] UriHandler: unexpected exception when handling "/lambda/load-function": 'Error: User cancelled operation\n' +
  '\t -> Error: User opted out of console login despite no active connection'
Screenshot 2026-02-23 at 5 15 09 PM

if (!activeConnection) {
const proceed = await promptConsoleLogin(name)
if (!proceed) {
throw new ToolkitError('User opted out of console login despite no active connection', { cancelled: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would this be an error/Exception? Isn't just a decision from the customer? Does this show a popup with this "error" message? (if the user just hit cancelled, do they need to see a message about that?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for checking this. This error will not pop up to customer.

We will record the reason code of this "cancellation" in telemetry. User will still see this error message in the AWS Toolkit logs if they investigate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, I think it should be logged if we want that info but not be an error for the customer

@keenwilson keenwilson force-pushed the fix/ask-before-fallback-console-login branch from 5963d5a to f3af6a6 Compare February 24, 2026 03:58
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