Skip to content

fix(amazonq): cancel chat export doesn't bubble error up to user #5723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 15, 2025

Conversation

samgst-amazon
Copy link
Contributor

Clicking cancel after save popup window would bubble up an error to the user in the IDE, and also print the error to the chat UI.

This change throws the right error when a user selects cancel on the save window and filters out the error from being printed in the chat.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@samgst-amazon samgst-amazon requested review from a team as code owners May 15, 2025 21:24
Copy link

github-actions bot commented May 15, 2025

Qodana Community for JVM

1 new problem were found

Inspection name Severity Problems
Accessor call that can be replaced with property access syntax ◽️ Notice 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@@ -230,8 +233,7 @@ class AmazonQLanguageClientImpl(private val project: Project) : AmazonQLanguageC

chosenFile?.let {
ShowSaveFileDialogResult(chosenFile.file.path)
// TODO: Add error state shown in chat ui instead of throwing
} ?: throw Error("Export failed")
} ?: throw ResponseErrorException(ResponseError(ResponseErrorCode.RequestCancelled, "Export cancelled by user", null))
Copy link
Contributor

Choose a reason for hiding this comment

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

lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need to throw this here to get the specific RequestCancelled error otherwise the ResponseErrorCode is InternalError which I think is a little too generic and I'm afraid it may unintentionally catch things. Is there any other reason the chosenFile would be null?

Copy link
Contributor

Choose a reason for hiding this comment

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

seems like they either choose a file or they dont

Copy link
Contributor

Choose a reason for hiding this comment

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

The other error condition that I can think of here is if a file is chosen which is not html or md if it exists but with the filtering dont think a user should run into this

samgst-amazon and others added 4 commits May 15, 2025 15:24
…kits/jetbrains/services/amazonq/webview/BrowserConnector.kt

Co-authored-by: Richard Li <742829+rli@users.noreply.github.com>
…kits/jetbrains/services/amazonq/webview/BrowserConnector.kt

Co-authored-by: Richard Li <742829+rli@users.noreply.github.com>
val cause = if (e is CompletionException) e.cause else e

// dont post error to UI if user cancels export
if (cause is ResponseErrorException && cause.responseError.code == ResponseErrorCode.RequestCancelled.getValue()) {

Check notice

Code scanning / QDJVMC

Accessor call that can be replaced with property access syntax Note

Use of getter method instead of property access syntax
@rli rli merged commit 6b1c4a7 into feature/q-lsp-chat May 15, 2025
11 of 16 checks passed
@rli rli deleted the samgst/q-lsp-chat-export-cancel branch May 15, 2025 23:25
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