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

Amazon Q: Added telemetry metrics and modified customer facing messages for Q Codescans. #4442

Merged
merged 29 commits into from May 15, 2024

Conversation

laileni-aws
Copy link
Contributor

@laileni-aws laileni-aws commented May 7, 2024

Types of changes

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

Description

  • Inconsistent customer facing messages and telemetry events in codescan.

Solution

  • Added customer facing error messages by removing existing to keep consistent.
  • Amazon Q: You have reached the monthly limit for project scans.
  • Amazon Q encountered an error while scanning for security issues. Please try again later.
  • Amazon Q: No workspace folders found
  • Amazon Q: Project does not contain valid files to scan
  • Amazon Q: The selected project exceeds the input artifact limit. Try again with a smaller project. For more information about scan limits, see the Amazon Q documentation
  • Amazon Q: The selected file exceeds the input artifact limit. Try again with a smaller file. For more information about scan limits, see the Amazon Q documentation
  • Added necessary telemetry events to understand the customer facing errors at different stages in Kibana.
  • Removed redundant Log.error to keep logs clean.

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 marked this pull request as ready for review May 9, 2024 17:25
@laileni-aws laileni-aws requested review from a team as code owners May 9, 2024 17:25
@laileni-aws laileni-aws changed the title Aligning Customer facing messages and telemetry events in both IDE's Amazon Q: Added telemetry metrics and modified customer facing messages for Q Codescans. May 9, 2024
val connection = it.connection as HttpURLConnection
connection.setFixedLengthStreamingMode(fileToUpload.length())
IoUtils.copy(fileToUpload.inputStream(), connection.outputStream)
} catch (e: IOException) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we catch and rethrow here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed try catch at parent function createUploadUrlAndUpload and tried to add this at individual step to get precise error message to telemetry.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the catch blocks here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a potential chance of IOException so I handled IOException too in the catch block. We need catch block to throw uploadArtifactFailedError if required, we can remove catch for IOException.

val connection = it.connection as HttpURLConnection
connection.setFixedLengthStreamingMode(fileToUpload.length())
IoUtils.copy(fileToUpload.inputStream(), connection.outputStream)
} catch (e: IOException) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the catch blocks here?

@@ -168,6 +169,15 @@ class CodeWhispererCodeFileScanTest : CodeWhispererCodeScanTestBase(PythonCodeIn
)
}

@Test
Copy link
Contributor

@manodnyab manodnyab May 14, 2024

Choose a reason for hiding this comment

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

Duplicate test?

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 thought to write test for both File scan and project scan but removed this.

Copy link

sonarcloud bot commented May 15, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@laileni-aws laileni-aws merged commit 16bc1a9 into aws:main May 15, 2024
9 of 11 checks passed
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