Skip to content

Commit b4433e7

Browse files
dhasani23David Hasani
andauthored
fix(amazonq): show users a notification when download fails (#4824)
* fix(amazonq): show notification on download failure * delete file * add error message * add changelog entry * update error message --------- Co-authored-by: David Hasani <[email protected]>
1 parent dbecc43 commit b4433e7

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q Code Transformation: show an error notification when download diff fails"
4+
}

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/ArtifactHandler.kt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ import software.aws.toolkits.jetbrains.core.coroutines.getCoroutineBgContext
2727
import software.aws.toolkits.jetbrains.core.coroutines.projectCoroutineScope
2828
import software.aws.toolkits.jetbrains.core.credentials.sso.bearer.NoTokenInitializedException
2929
import software.aws.toolkits.jetbrains.services.amazonq.CODE_TRANSFORM_TROUBLESHOOT_DOC_DOWNLOAD_ERROR_OVERVIEW
30+
import software.aws.toolkits.jetbrains.services.amazonq.CODE_TRANSFORM_TROUBLESHOOT_DOC_DOWNLOAD_EXPIRED
3031
import software.aws.toolkits.jetbrains.services.codemodernizer.client.GumbyClient
3132
import software.aws.toolkits.jetbrains.services.codemodernizer.commands.CodeTransformMessageListener
33+
import software.aws.toolkits.jetbrains.services.codemodernizer.constants.getDownloadedArtifactTextFromType
3234
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeModernizerArtifact
3335
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransformFailureBuildLog
3436
import software.aws.toolkits.jetbrains.services.codemodernizer.model.CodeTransformHilDownloadArtifact
@@ -275,10 +277,12 @@ class ArtifactHandler(private val project: Project, private val clientAdaptor: G
275277
}
276278

277279
fun notifyUnableToDownload(error: DownloadFailureReason) {
278-
// Inform chat about failure
280+
// Inform about failure
279281
LOG.error { "Unable to download artifact: $error" }
280282
CodeTransformMessageListener.instance.onDownloadFailure(error)
281283

284+
val artifactText = getDownloadedArtifactTextFromType(error.artifactType)
285+
282286
// Display notification balloon if applicable
283287
when (error) {
284288
is DownloadFailureReason.PROXY_WILDCARD_ERROR -> notifyStickyWarn(
@@ -310,8 +314,25 @@ class ArtifactHandler(private val project: Project, private val clientAdaptor: G
310314
)
311315
}
312316

313-
is DownloadFailureReason.OTHER, is DownloadFailureReason.INVALID_ARTIFACT -> {
314-
// No notification, only chat update
317+
is DownloadFailureReason.INVALID_ARTIFACT -> {
318+
if (error.artifactType == TransformationDownloadArtifactType.CLIENT_INSTRUCTIONS) {
319+
notifyStickyWarn(
320+
message("codemodernizer.notification.warn.download_failed_client_instructions_expired"),
321+
CODE_TRANSFORM_TROUBLESHOOT_DOC_DOWNLOAD_EXPIRED,
322+
)
323+
} else {
324+
notifyStickyWarn(
325+
message("codemodernizer.notification.warn.download_failed_invalid_artifact", artifactText),
326+
CODE_TRANSFORM_TROUBLESHOOT_DOC_DOWNLOAD_EXPIRED,
327+
)
328+
}
329+
}
330+
331+
is DownloadFailureReason.OTHER -> {
332+
notifyStickyWarn(
333+
message("codemodernizer.notification.warn.download_failed_other.content", artifactText, error.errorMessage),
334+
CODE_TRANSFORM_TROUBLESHOOT_DOC_DOWNLOAD_ERROR_OVERVIEW,
335+
)
315336
}
316337
}
317338
}

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ fun buildDownloadFailureChatContent(downloadFailureReason: DownloadFailureReason
536536
)
537537
}
538538

539-
private fun getDownloadedArtifactTextFromType(artifactType: TransformationDownloadArtifactType): String =
539+
fun getDownloadedArtifactTextFromType(artifactType: TransformationDownloadArtifactType): String =
540540
when (artifactType) {
541541
TransformationDownloadArtifactType.CLIENT_INSTRUCTIONS -> "upgraded code"
542542
TransformationDownloadArtifactType.LOGS -> "build log"

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ codemodernizer.chat.message.hil.user_rejected=I'll continue upgrading your modul
606606
codemodernizer.chat.message.local_build_begin=I'm building your module. This can take up to 10 minutes, depending on the size of your module.
607607
codemodernizer.chat.message.local_build_failed=Sorry, I couldn't run the Maven clean install command to build your module.
608608
codemodernizer.chat.message.local_build_success=I was able to build your project and will start uploading your code.
609-
codemodernizer.chat.message.reauth_success=Please start a new transformation job and try submitting the job again.
610609
codemodernizer.chat.message.result.fail=Sorry, I ran into an issue during the transformation. Please try again.
611610
codemodernizer.chat.message.result.fail_initial_build=I am having trouble building your project in the secure build environment and couldn't complete the transformation.
612611
codemodernizer.chat.message.result.fail_initial_build_no_build_log=I am having trouble building your project in the secure build environment: {0}.
@@ -646,9 +645,6 @@ codemodernizer.explorer.show_transformation_plan_title=View your code transforma
646645
codemodernizer.explorer.show_transformation_summary_title=View your code transformation summary
647646
codemodernizer.explorer.stop_migration_job=Stop Transformation
648647
codemodernizer.file.invalid_pom_version=Amazon Q experienced an issue upgrading this dependency version. Use Amazon Q chat to upgrade the version of this dependency to a Java 17 compatible version.
649-
codemodernizer.manager.job_failed_content=The transformation job failed when you were away with reason: {0}
650-
codemodernizer.manager.job_finished_content=The transformation job completed while you were away
651-
codemodernizer.manager.job_finished_title=Job Finished
652648
codemodernizer.manager.job_ongoing_content=Amazon Q is still transforming your code. To see the current status of the transformation, go to the Transformation Hub.
653649
codemodernizer.manager.job_ongoing_title=Code Transformation ongoing
654650
codemodernizer.migration_plan.body.info.action_column=Action
@@ -699,7 +695,10 @@ codemodernizer.notification.info.transformation_stop.content=You cancelled the t
699695
codemodernizer.notification.info.transformation_stop.title=Transformation cancelled
700696
codemodernizer.notification.info.view_troubleshooting_guide=View troubleshooting guide
701697
codemodernizer.notification.warn.action.reauthenticate=Reauthenticate
698+
codemodernizer.notification.warn.download_failed_client_instructions_expired=Your transformation is not available anymore. Your code and transformation summary are deleted 24 hours after the transformation completes. Please try starting the transformation again.
702699
codemodernizer.notification.warn.download_failed_expired_credentials.content=Unable to download results as your credentials expired, please reauthenticate to Q and try again.
700+
codemodernizer.notification.warn.download_failed_invalid_artifact=Amazon Q was unable to find your {0}. Artifacts are deleted after 24 hours. Please try starting the transformation again.
701+
codemodernizer.notification.warn.download_failed_other.content=Amazon Q ran into an issue while trying to download your {0}. Please try again. {1}
703702
codemodernizer.notification.warn.download_failed_ssl.content=Please make sure all your certificates for your proxy client have been set up correctly for your IDE.
704703
codemodernizer.notification.warn.download_failed_wildcard.content=Check your IDE proxy settings and remove any wildcard (*) references, and then try viewing the diff again.
705704
codemodernizer.notification.warn.expired_credentials.title=Your connection to Q has expired

0 commit comments

Comments
 (0)