Skip to content

Conversation

@ctlai95
Copy link
Contributor

@ctlai95 ctlai95 commented Jan 4, 2025

Problem

Code fix errors are not handled correctly, only shows a generic error notification and webview is not updated.

Solution

Surface the server error to the UI

image
  • 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.

@ctlai95 ctlai95 marked this pull request as ready for review January 4, 2025 01:39
@ctlai95 ctlai95 requested review from a team as code owners January 4, 2025 01:39
issue: targetIssue,
isGenerateFixLoading: false,
isGenerateFixError: true,
generateFixError: getErrorMsg(err as AWSError, true),
Copy link
Contributor

@ashishrp-aws ashishrp-aws Jan 6, 2025

Choose a reason for hiding this comment

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

@ctlai95 can we use user friendly error messages instead passing the service error straight to user? Like how we handle code review errors.

issue: targetIssue,
isGenerateFixLoading: false,
isGenerateFixError: true,
generateFixError: getErrorMsg(err as AWSError, true),
Copy link
Contributor

Choose a reason for hiding this comment

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

Look to add in the following before to avoid needing to cast:

if (!(err instanceof Error)) {
  throw new Error('Unexpected non error', err) // modify this as needed
}

Copy link
Contributor

Choose a reason for hiding this comment

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

using isAwsError may be better:

export function isAwsError(error: unknown): error is AWSError & { error_description?: string } {

filePath?: string
isGenerateFixLoading?: boolean
isGenerateFixError?: boolean
generateFixError?: string | null
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be good enough

Suggested change
generateFixError?: string | null
generateFixError?: string

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 null is required for this since I want to maintain this behavior where the following will remove the error from the webview:

updateSecurityIssueWebview({
  ...
  generateFixError: null
})

while the absence of the field should not remove it

updateSecurityIssueWebview({
  ...
  issue: newIssue
})

public setIsGenerateFixError(isGenerateFixError: boolean) {
this.isGenerateFixError = isGenerateFixError
this.onChangeGenerateFixError.fire(isGenerateFixError)
public setGenerateFixError(generateFixError: string | null | undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can probably drop null

relativePath: '',
isGenerateFixLoading: false,
isGenerateFixError: false,
generateFixError: undefined as string | null | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be good enough. I think the types upstream may need to be modified

Suggested change
generateFixError: undefined as string | null | undefined,
generateFixError: undefined

private filePath: string | undefined
private isGenerateFixLoading: boolean = false
private isGenerateFixError: boolean = false
private generateFixError: string | null | undefined = undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Try

Suggested change
private generateFixError: string | null | undefined = undefined
private generateFixError: string | undefined = undefined

@nkomonen-amazon nkomonen-amazon merged commit f192573 into aws:master Jan 17, 2025
24 of 26 checks passed
karanA-aws pushed a commit to karanA-aws/aws-toolkit-vscode that referenced this pull request Jan 17, 2025
## Problem

Code fix errors are not handled correctly, only shows a generic error
notification and webview is not updated.


## Solution

Surface the server error to the UI

<img width="658" alt="image"
src="https://github.com/user-attachments/assets/6e0e72d1-7de1-415d-a4d4-891d94e6d7ea"
/>



---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
kevluu-aws pushed a commit to kevluu-aws/aws-toolkit-vscode that referenced this pull request Jan 23, 2025
## Problem

Code fix errors are not handled correctly, only shows a generic error
notification and webview is not updated.


## Solution

Surface the server error to the UI

<img width="658" alt="image"
src="https://github.com/user-attachments/assets/6e0e72d1-7de1-415d-a4d4-891d94e6d7ea"
/>



---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
chungjac pushed a commit to chungjac/aws-toolkit-vscode that referenced this pull request Jan 24, 2025
## Problem

Code fix errors are not handled correctly, only shows a generic error
notification and webview is not updated.


## Solution

Surface the server error to the UI

<img width="658" alt="image"
src="https://github.com/user-attachments/assets/6e0e72d1-7de1-415d-a4d4-891d94e6d7ea"
/>



---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
s7ab059789 pushed a commit to s7ab059789/aws-toolkit-vscode that referenced this pull request Feb 19, 2025
## Problem

Code fix errors are not handled correctly, only shows a generic error
notification and webview is not updated.


## Solution

Surface the server error to the UI

<img width="658" alt="image"
src="https://github.com/user-attachments/assets/6e0e72d1-7de1-415d-a4d4-891d94e6d7ea"
/>



---

- 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](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.
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.

4 participants