From 708aff6fe332b55d34158092bb83ad3e1b872ec7 Mon Sep 17 00:00:00 2001 From: Vieltojarvi Date: Tue, 3 Dec 2024 14:55:09 -0800 Subject: [PATCH 1/5] catch a form of EPERM error --- packages/backend-deployer/src/cdk_error_mapper.test.ts | 6 ++++++ packages/backend-deployer/src/cdk_error_mapper.ts | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/backend-deployer/src/cdk_error_mapper.test.ts b/packages/backend-deployer/src/cdk_error_mapper.test.ts index 3850467a35..a4f9d4952b 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.test.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.test.ts @@ -359,6 +359,12 @@ const testErrorMappings = [ errorName: 'FilePermissionsError', expectedDownstreamErrorMessage: `EACCES: permission denied, unlink '.amplify/artifacts/cdk.out/synth.lock'`, }, + { + errorMessage: `EPERM: operation not permitted, rename 'C:/Users/someUser/amplify/artifacts/cdk.out/synth.lock.6785_1' → 'C:/Users/someUser/amplify/artifacts/cdk.out/synth.lock'`, + expectedTopLevelErrorMessage: `Not permitted to rename file: 'C:/Users/someUser/amplify/artifacts/cdk.out/synth.lock.6785_1'`, + errorName: 'FilePermissionsError', + expectedDownstreamErrorMessage: undefined, + }, { errorMessage: `This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version. (Cloud assembly schema version mismatch: Maximum schema version supported is 36.0.0, but found 36.1.1)`, diff --git a/packages/backend-deployer/src/cdk_error_mapper.ts b/packages/backend-deployer/src/cdk_error_mapper.ts index 949a9212f3..5e68294395 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.ts @@ -184,6 +184,15 @@ export class CdkErrorMapper { errorName: 'FilePermissionsError', classification: 'ERROR', }, + { + errorRegex: + /EPERM: operation not permitted, rename (?.*) → 'C:(.*)synth.lock(.*)/, + humanReadableErrorMessage: 'Not permitted to rename file: {fileName}', + resolutionMessage: + 'Check that you have the right permissions to rename this file and try running the command again', + errorName: 'FilePermissionsError', + classification: 'ERROR', + }, { errorRegex: new RegExp( `\\[ERR_MODULE_NOT_FOUND\\]:(.*)${this.multiLineEolRegex}|Error: Cannot find module (.*)` From 07083edbaf7fe2247ccb8f9e4e2179748b91763d Mon Sep 17 00:00:00 2001 From: Vieltojarvi Date: Tue, 3 Dec 2024 14:58:54 -0800 Subject: [PATCH 2/5] update to stack in failed state --- packages/backend-deployer/src/cdk_error_mapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend-deployer/src/cdk_error_mapper.ts b/packages/backend-deployer/src/cdk_error_mapper.ts index 5e68294395..e064d22eac 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.ts @@ -229,7 +229,7 @@ export class CdkErrorMapper { humanReadableErrorMessage: 'The CloudFormation deletion failed due to {stackName} being in DELETE_FAILED state. Ensure all your resources are able to be deleted', resolutionMessage: - 'The following resource(s) failed to delete: {resources}. Ensure they are in a state where they can be deleted. Find more information in the CloudFormation AWS Console for this stack.', + 'The following resource(s) failed to delete: {resources}. Check the error message for more details and ensure your resources are in a state where they can be deleted. Check the CloudFormation AWS Console for this stack to find additional information.', errorName: 'CloudFormationDeletionError', classification: 'ERROR', }, From 08c59d3da8f13f52d2ef3b9f701102e752ff830e Mon Sep 17 00:00:00 2001 From: Vieltojarvi Date: Tue, 3 Dec 2024 15:01:14 -0800 Subject: [PATCH 3/5] added changeset --- .changeset/purple-news-do.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/purple-news-do.md diff --git a/.changeset/purple-news-do.md b/.changeset/purple-news-do.md new file mode 100644 index 0000000000..4c64d168bb --- /dev/null +++ b/.changeset/purple-news-do.md @@ -0,0 +1,5 @@ +--- +'@aws-amplify/backend-deployer': patch +--- + +Catches most common EPERM error and update to resolution message for stack in failed state From 92f564785df18e9e4fa4a59533ae75c9ab716444 Mon Sep 17 00:00:00 2001 From: Vieltojarvi Date: Tue, 3 Dec 2024 17:06:28 -0800 Subject: [PATCH 4/5] updates to regex and resolution message --- packages/backend-deployer/src/cdk_error_mapper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend-deployer/src/cdk_error_mapper.ts b/packages/backend-deployer/src/cdk_error_mapper.ts index e064d22eac..5099b10f1e 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.ts @@ -186,10 +186,10 @@ export class CdkErrorMapper { }, { errorRegex: - /EPERM: operation not permitted, rename (?.*) → 'C:(.*)synth.lock(.*)/, + /EPERM: operation not permitted, rename (?(.*)\/synth\.lock\.\S+) → '(.*)\/synth\.lock'/, humanReadableErrorMessage: 'Not permitted to rename file: {fileName}', resolutionMessage: - 'Check that you have the right permissions to rename this file and try running the command again', + 'Try running the command again and check that no other process has this file open and that you have the right permissions to rename this file', errorName: 'FilePermissionsError', classification: 'ERROR', }, From 1234ebb8a7dc4f5e16c0ca48daf9b182548132ea Mon Sep 17 00:00:00 2001 From: Vieltojarvi Date: Wed, 4 Dec 2024 09:13:53 -0800 Subject: [PATCH 5/5] adjusted resolution message --- packages/backend-deployer/src/cdk_error_mapper.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/backend-deployer/src/cdk_error_mapper.ts b/packages/backend-deployer/src/cdk_error_mapper.ts index 5099b10f1e..5b121ea673 100644 --- a/packages/backend-deployer/src/cdk_error_mapper.ts +++ b/packages/backend-deployer/src/cdk_error_mapper.ts @@ -188,8 +188,7 @@ export class CdkErrorMapper { errorRegex: /EPERM: operation not permitted, rename (?(.*)\/synth\.lock\.\S+) → '(.*)\/synth\.lock'/, humanReadableErrorMessage: 'Not permitted to rename file: {fileName}', - resolutionMessage: - 'Try running the command again and check that no other process has this file open and that you have the right permissions to rename this file', + resolutionMessage: `Try running the command again and ensure that only one instance of sandbox is running. If it still doesn't work check the permissions of '.amplify' folder`, errorName: 'FilePermissionsError', classification: 'ERROR', },