Skip to content

Commit 6015595

Browse files
ShadowCat567Vieltojarvi
andauthored
cdk error mapping EPERM errors relating to synth.lock (#2293)
* catch a form of EPERM error * update to stack in failed state * added changeset * updates to regex and resolution message * adjusted resolution message --------- Co-authored-by: Vieltojarvi <[email protected]>
1 parent d227f96 commit 6015595

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.changeset/purple-news-do.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-deployer': patch
3+
---
4+
5+
Catches most common EPERM error and update to resolution message for stack in failed state

packages/backend-deployer/src/cdk_error_mapper.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,12 @@ const testErrorMappings = [
359359
errorName: 'FilePermissionsError',
360360
expectedDownstreamErrorMessage: `EACCES: permission denied, unlink '.amplify/artifacts/cdk.out/synth.lock'`,
361361
},
362+
{
363+
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'`,
364+
expectedTopLevelErrorMessage: `Not permitted to rename file: 'C:/Users/someUser/amplify/artifacts/cdk.out/synth.lock.6785_1'`,
365+
errorName: 'FilePermissionsError',
366+
expectedDownstreamErrorMessage: undefined,
367+
},
362368
{
363369
errorMessage: `This CDK CLI is not compatible with the CDK library used by your application. Please upgrade the CLI to the latest version.
364370
(Cloud assembly schema version mismatch: Maximum schema version supported is 36.0.0, but found 36.1.1)`,

packages/backend-deployer/src/cdk_error_mapper.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ export class CdkErrorMapper {
184184
errorName: 'FilePermissionsError',
185185
classification: 'ERROR',
186186
},
187+
{
188+
errorRegex:
189+
/EPERM: operation not permitted, rename (?<fileName>(.*)\/synth\.lock\.\S+) '(.*)\/synth\.lock'/,
190+
humanReadableErrorMessage: 'Not permitted to rename file: {fileName}',
191+
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`,
192+
errorName: 'FilePermissionsError',
193+
classification: 'ERROR',
194+
},
187195
{
188196
errorRegex: new RegExp(
189197
`\\[ERR_MODULE_NOT_FOUND\\]:(.*)${this.multiLineEolRegex}|Error: Cannot find module (.*)`
@@ -220,7 +228,7 @@ export class CdkErrorMapper {
220228
humanReadableErrorMessage:
221229
'The CloudFormation deletion failed due to {stackName} being in DELETE_FAILED state. Ensure all your resources are able to be deleted',
222230
resolutionMessage:
223-
'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.',
231+
'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.',
224232
errorName: 'CloudFormationDeletionError',
225233
classification: 'ERROR',
226234
},

0 commit comments

Comments
 (0)