Skip to content
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

Adding Error message to chat window if UploadArtifactToS3 fails in Gumby #4339

Closed
wants to merge 15 commits into from

Conversation

laileni-aws
Copy link
Contributor

@laileni-aws laileni-aws commented Apr 23, 2024

Types of changes

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

Description

  • Existing error message is generic and provide little context for upload artifact failure.

Solution

  • Change in Error message for uploadArtifactToS3 in Gumby .
  • Provides information about the error with link in the chat.

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.

@laileni-aws laileni-aws changed the title Adding Error message to UploadArtifact URL Adding Error message to UploadArtifact URL in Gumby Apr 23, 2024
dhasani23
dhasani23 previously approved these changes Apr 23, 2024
@@ -369,6 +369,13 @@ class CodeModernizerManager(private val project: Project) : PersistentStateCompo
)
}

is CodeModernizerStartJobResult.UploadArtifactToS3Failure -> {
CodeModernizerJobCompletedResult.UnableToCreateJob(
message("codemodernizer.notification.warn.unable_to_start_job_due_to_upload_failure"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to be:
message("codemodernizer.notification.warn.unable_to_start_job_due_to_upload_failure", URL)

to replace the {0}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We dont need to pass here I think so as this will be retrieved directly from https://github.com/aws/aws-toolkit-jetbrains/pull/4339/files#diff-d5d5f0160522116b64d9ad48daa882f8f802d086797a0bfc86cc0363b1f43c3eR158

As I followed the above CodeModernizerStartJobResult.UnableToStartJob

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's going to be retrieved, I've never used it like that

@laileni-aws laileni-aws marked this pull request as ready for review April 23, 2024 14:40
@laileni-aws laileni-aws requested review from a team as code owners April 23, 2024 14:40
@laileni-aws laileni-aws changed the title Adding Error message to UploadArtifact URL in Gumby Adding Error message to chat window if UploadArtifactToS3 fails in Gumby Apr 24, 2024
@rli rli deleted the branch aws:main April 24, 2024 05:40
@rli rli closed this Apr 24, 2024
@rli rli reopened this Apr 24, 2024
@rli rli changed the base branch from feature/cw-proactive-scan to feature/q-extension April 24, 2024 05:42
@@ -154,7 +154,9 @@ class CodeModernizerSession(
} catch (e: Exception) {
state.putJobHistory(sessionContext, TransformationStatus.FAILED)
state.currentJobStatus = TransformationStatus.FAILED
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to discern if we can modify e: Exception to some sort of AWS SDK error object like AwsServiceException -> https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/error-handling.html

You should be able to do some error handling for this type of error object and directly report this on a 403 with:

        } catch(e: AwsServiceException) {
            if (e.statusCode() === 403 && e.awsErrorDetails().serviceName() === "S3") {
 CodeModernizerStartJobResult.UnabletoStartOrUploadJob(
                "https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/security_iam_manage-access-with-policies.html")
            } else {
                 CodeModernizerStartJobResult.UnableToStartJob(e.message.toString())
            }
        }

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not exactly sure about the service name string, but since startJob and s3Upload are in the same try/catch, we could possibly use this to discern the difference between the two.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rli Is the AwsServiceException the right way to capture AWS SDK specific issues in Kotlin?

Copy link
Contributor

Choose a reason for hiding this comment

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

S3Exception / CodeWhisperer[Streaming]Exception?
avoid introspecting status codes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall I go with S3Exception or AwsServiceException to capture the upload failure to S3? @damntrecky

@@ -7,6 +7,7 @@ sealed class CodeModernizerStartJobResult {
data class ZipCreationFailed(val reason: String) : CodeModernizerStartJobResult()
data class Started(val jobId: JobId) : CodeModernizerStartJobResult()
data class UnableToStartJob(val exception: String) : CodeModernizerStartJobResult()
data class UnabletoStartOrUploadJob(val url: String) : CodeModernizerStartJobResult()
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to UnabletoUploadJob and we can keep UnableToStartJob a separate error.

@rli rli deleted the branch aws:main April 29, 2024 21:12
@rli rli closed this Apr 29, 2024
@rli rli reopened this Apr 29, 2024
@rli rli changed the base branch from feature/q-extension to main April 29, 2024 21:17
Copy link

sonarcloud bot commented Apr 29, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

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.

None yet

4 participants