Skip to content

Commit 51190aa

Browse files
dhasani23David Hasani
andauthored
fix(CodeTransform): show link to docs after errors (#4477)
* fix(CodeTransform): show link to docs after errors * nit: comment changes --------- Co-authored-by: David Hasani <[email protected]>
1 parent 82b6a9b commit 51190aa

File tree

6 files changed

+85
-64
lines changed

6 files changed

+85
-64
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Amazon Q CodeTransform: show link to documentation after errors"
4+
}

packages/toolkit/src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async function setMaven() {
174174
} else {
175175
transformByQState.setMavenName('mvn')
176176
}
177-
getLogger().info(`CodeTransform: using Maven ${transformByQState.getMavenName()}`)
177+
getLogger().info(`CodeTransformation: using Maven ${transformByQState.getMavenName()}`)
178178
}
179179

180180
async function validateJavaHome() {
@@ -218,11 +218,11 @@ async function validateJavaHome() {
218218
ignoreFocusOut: true,
219219
})
220220
if (!javaHome || !javaHome.trim()) {
221-
throw new ToolkitError('No JAVA_HOME provided', { code: 'NoJavaHomePath' })
221+
throw new ToolkitError('No JDK path provided', { code: 'NoJavaHomePath' })
222222
}
223223
transformByQState.setJavaHome(javaHome.trim())
224224
getLogger().info(
225-
`CodeTransform: using JAVA_HOME = ${transformByQState.getJavaHome()} since source JDK does not match Maven JDK`
225+
`CodeTransformation: using JAVA_HOME = ${transformByQState.getJavaHome()} since source JDK does not match Maven JDK`
226226
)
227227
}
228228
}
@@ -331,16 +331,17 @@ export async function pollTransformationStatusUntilPlanReady(jobId: string) {
331331
try {
332332
await pollTransformationJob(jobId, CodeWhispererConstants.validStatesForGettingPlan)
333333
} catch (error) {
334-
const errorMessage = 'Failed to poll transformation job for plan availability, or job itself failed'
335-
getLogger().error(errorMessage, error)
334+
const errorMessage = 'Failed to get job status or job itself failed'
335+
getLogger().error(`CodeTransformation: ${errorMessage}`, error)
336+
transformByQState.setJobFailureErrorMessage(errorMessage)
336337
throw new ToolkitError(errorMessage, { cause: error as Error })
337338
}
338339
let plan = undefined
339340
try {
340341
plan = await getTransformationPlan(jobId)
341342
} catch (error) {
342343
const errorMessage = 'Failed to get transformation plan'
343-
getLogger().error(errorMessage, error)
344+
getLogger().error(`CodeTransformation: ${errorMessage}`, error)
344345
transformByQState.setJobFailureErrorMessage(errorMessage)
345346
throw new ToolkitError(errorMessage, { cause: error as Error })
346347
}
@@ -359,7 +360,7 @@ export async function pollTransformationStatusUntilComplete(jobId: string) {
359360
status = await pollTransformationJob(jobId, CodeWhispererConstants.validStatesForCheckingDownloadUrl)
360361
} catch (error) {
361362
const errorMessage = 'Failed to get transformation job status'
362-
getLogger().error(errorMessage, error)
363+
getLogger().error(`CodeTransformation: ${errorMessage}`, error)
363364
transformByQState.setJobFailureErrorMessage(errorMessage)
364365
throw new ToolkitError(errorMessage, { cause: error as Error })
365366
}
@@ -370,7 +371,7 @@ export async function pollTransformationStatusUntilComplete(jobId: string) {
370371
export async function finalizeTransformationJob(status: string) {
371372
if (!(status === 'COMPLETED' || status === 'PARTIALLY_COMPLETED')) {
372373
const errorMessage = 'Failed to complete transformation'
373-
getLogger().error(errorMessage)
374+
getLogger().error(`CodeTransformation: ${errorMessage}`)
374375
sessionPlanProgress['transformCode'] = StepProgress.Failed
375376
transformByQState.setJobFailureErrorMessage(errorMessage)
376377
throw new ToolkitError(errorMessage, { code: 'JobDidNotSucceed' })
@@ -395,15 +396,15 @@ export async function validateTransformationJob() {
395396
try {
396397
openProjects = await getOpenProjects()
397398
} catch (err) {
398-
getLogger().error('Failed to get open projects: ', err)
399+
getLogger().error(`CodeTransformation: Failed to get open projects: ${err}`)
399400
throw err
400401
}
401402

402403
let validProjects = undefined
403404
try {
404405
validProjects = await validateOpenProjects(openProjects)
405406
} catch (err) {
406-
getLogger().error('Selected project is not Java 8, not Java 11, or does not use Maven', err)
407+
getLogger().error(`CodeTransformation: No open projects contain a .java file or a pom.xml file ${err}`)
407408
throw err
408409
}
409410

@@ -517,8 +518,8 @@ export async function transformationJobErrorHandler(error: any) {
517518
codeTransformTelemetryState.setResultStatus('JobFailed')
518519
let displayedErrorMessage =
519520
transformByQState.getJobFailureErrorMessage() || CodeWhispererConstants.transformByQFailedMessage
520-
if (transformByQState.getJobFailureReason() !== '') {
521-
displayedErrorMessage += `: ${transformByQState.getJobFailureReason()}`
521+
if (transformByQState.getJobFailureMetadata() !== '') {
522+
displayedErrorMessage += `: ${transformByQState.getJobFailureMetadata()}`
522523
}
523524
void vscode.window.showErrorMessage(displayedErrorMessage)
524525
}
@@ -534,8 +535,7 @@ export async function transformationJobErrorHandler(error: any) {
534535
if (sessionPlanProgress['returnCode'] !== StepProgress.Succeeded) {
535536
sessionPlanProgress['returnCode'] = StepProgress.Failed
536537
}
537-
// Log error to VSCode logs
538-
getLogger().error('Amazon Q Code Transform', error)
538+
getLogger().error(`CodeTransformation: ${error}`)
539539
}
540540

541541
export async function cleanupTransformationJob(intervalId: NodeJS.Timeout | undefined) {
@@ -578,7 +578,7 @@ export async function confirmStopTransformByQ(
578578
stopTransformByQButton
579579
)
580580
if (resp === stopTransformByQButton && transformByQState.isRunning()) {
581-
getLogger().verbose('User requested to stop transform by Q. Stopping transform by Q.')
581+
getLogger().info('CodeTransformation: User requested to stop transformation. Stopping transformation.')
582582
transformByQState.setToCancelled()
583583
await vscode.commands.executeCommand('aws.amazonq.refresh')
584584
await vscode.commands.executeCommand('setContext', 'gumby.isStopButtonAvailable', false)

packages/toolkit/src/codewhisperer/models/constants.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,18 @@ export const newCustomizationMessage = 'You have access to new CodeWhisperer cus
274274

275275
export const newCustomizationAvailableKey = 'CODEWHISPERER_NEW_CUSTOMIZATION_AVAILABLE'
276276

277-
// Transform by Q
277+
// Amazon Q CodeTransformation
278278

279279
export const selectProjectPrompt = 'Select the project you want to transform'
280280

281281
export const unsupportedJavaVersionSelectedMessage =
282-
'Thank you for trying our product. We currently only support Java 8 and 11. We appreciate you taking the time to use the product, and hope to expand support to more Java versions in the future. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html'
282+
'Thank you for trying our product. We currently only support Java 8 and 11. We appreciate you taking the time to use the product, and hope to expand support to more Java versions in the future. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html#prerequisites'
283283

284284
export const transformByQWindowTitle = 'Amazon Q Code Transformation'
285285

286-
export const stopTransformByQMessage = 'Stop Transformation?'
286+
export const stopTransformByQMessage = 'Stop transformation?'
287287

288-
export const stoppingTransformByQMessage = 'Stopping Transformation...'
288+
export const stoppingTransformByQMessage = 'Stopping transformation...'
289289

290290
export const transformByQFailedMessage = 'Transformation failed'
291291

@@ -296,10 +296,10 @@ export const transformByQCompletedMessage = 'Transformation completed'
296296
export const transformByQPartiallyCompletedMessage = 'Transformation partially completed'
297297

298298
export const noPomXmlFoundMessage =
299-
'None of your open Java projects are supported by Amazon Q Code Transformation. We were unable to find a pom.xml in any of your Java projects. We only support Java projects built on Maven at the moment. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html'
299+
'None of your open Java projects are supported by Amazon Q Code Transformation. We were unable to find a pom.xml in any of your Java projects. We only support Java projects built on Maven at the moment. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html#prerequisites'
300300

301301
export const noActiveIdCMessage =
302-
'Amazon Q Code Transformation requires an active IAM Identity Center connection. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html'
302+
'Amazon Q Code Transformation requires an active IAM Identity Center connection. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html#prerequisites'
303303

304304
export const noOngoingJobMessage = 'No job is in-progress at the moment'
305305

@@ -309,26 +309,31 @@ export const cancellationInProgressMessage = 'Cancellation is in-progress'
309309

310310
export const errorStoppingJobMessage = 'Error stopping job'
311311

312-
export const errorDownloadingDiffMessage = 'Amazon Q Code Transformation experienced an error when downloading the diff'
312+
export const errorDownloadingDiffMessage =
313+
'Amazon Q Code Transformation experienced an error when downloading the diff. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html#w24aac14c20c19c11'
314+
315+
export const errorDeserializingDiffMessage =
316+
'Amazon Q Code Transformation experienced an error during the deserialization of the downloaded result archive. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html#w24aac14c20c19c11'
317+
318+
export const buildLogsDocumentationMessage =
319+
'Please also see https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/troubleshooting-code-transformation.html#w24aac14c20c19b7'
313320

314321
export const viewProposedChangesMessage =
315322
'Transformation job completed. You can view the transformation summary along with the proposed changes and accept or reject them in the Proposed Changes panel.'
316323

317324
export const changesAppliedMessage = 'Changes applied'
318325

319326
export const noSupportedJavaProjectsFoundMessage =
320-
'None of your open projects are supported by Amazon Q Code Transformation. We were unable to find a Java project. We only support Java projects built on Maven at the moment. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html'
327+
'None of your open projects are supported by Amazon Q Code Transformation. We were unable to find a Java project. We only support Java projects built on Maven at the moment. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html#prerequisites'
321328

322329
export const dependencyDisclaimer =
323330
'Please confirm you are ready to proceed with the transformation. Amazon Q Code Transformation will upload the application code and its dependency binaries from your machine to start the upgrade. If you have not yet compiled the application on your local machine, please do so once before starting the upgrade. Install Maven to ensure all module dependencies are picked for Transformation.'
324331

325332
export const dependencyFolderName = 'transformation_dependencies_temp_'
326333

327-
export const installErrorMessage =
328-
'Failed to execute Maven install. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html'
334+
export const installErrorMessage = 'Failed to execute Maven install.'
329335

330-
export const dependencyErrorMessage =
331-
'Failed to execute Maven copy-dependencies. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html'
336+
export const dependencyErrorMessage = 'Failed to execute Maven copy-dependencies.'
332337

333338
export const planIntroductionMessage =
334339
'We reviewed your Java JAVA_VERSION_HERE application and generated a transformation plan. Any code changes made to your application will be done in the sandbox so as to not interfere with your working repository. Once the transformation job is done, we will share the new code which you can review before acccepting the code changes. In the meantime, you can work on your codebase and invoke Q Chat to answer questions about your codebase.'
@@ -347,7 +352,7 @@ export const nonWindowsJava11HomeHelpMessage =
347352
'Try running "/usr/libexec/java_home -v 11" in a terminal to find this. It should look something like "/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home"'
348353

349354
export const projectSizeTooLargeMessage =
350-
'Your project size exceeds the Amazon Q Code Transformation upload limit of 1GB. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html'
355+
'Your project size exceeds the Amazon Q Code Transformation upload limit of 1GB. Please see: https://docs.aws.amazon.com/amazonq/latest/aws-builder-use-ug/code-transformation.html#prerequisites'
351356

352357
export const JDK8VersionNumber = '52'
353358

packages/toolkit/src/codewhisperer/models/model.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export class TransformByQState {
281281

282282
private polledJobStatus: string = ''
283283

284-
private jobFailureReason: string = ''
284+
private jobFailureMetadata: string = ''
285285

286286
private payloadFilePath: string = ''
287287

@@ -361,8 +361,8 @@ export class TransformByQState {
361361
return this.projectCopyFilePath
362362
}
363363

364-
public getJobFailureReason() {
365-
return this.jobFailureReason
364+
public getJobFailureMetadata() {
365+
return this.jobFailureMetadata
366366
}
367367

368368
public getPayloadFilePath() {
@@ -453,8 +453,8 @@ export class TransformByQState {
453453
this.projectCopyFilePath = filePath
454454
}
455455

456-
public setJobFailureReason(reason: string) {
457-
this.jobFailureReason = reason
456+
public setJobFailureMetadata(data: string) {
457+
this.jobFailureMetadata = data
458458
}
459459

460460
public setPayloadFilePath(payloadFilePath: string) {

0 commit comments

Comments
 (0)