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

cdk error mapping EPERM errors relating to synth.lock #2293

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/purple-news-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/backend-deployer': patch
---

Catches most common EPERM error and update to resolution message for stack in failed state
6 changes: 6 additions & 0 deletions packages/backend-deployer/src/cdk_error_mapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an error that only appears to Windows users, so using Windows file path structure here

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)`,
Expand Down
11 changes: 10 additions & 1 deletion packages/backend-deployer/src/cdk_error_mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ export class CdkErrorMapper {
errorName: 'FilePermissionsError',
classification: 'ERROR',
},
{
errorRegex:
/EPERM: operation not permitted, rename (?<fileName>(.*)\/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',
Copy link
Contributor

Choose a reason for hiding this comment

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

synth.lock files are not managed by customers, but CDK. Customers would have no idea what "no other process has this file open" or "permissions to rename this file" might mean. I'd simplify to

Suggested change
'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',
'Try running the command again and ensure that only one sandbox instance is running. If it still doesn't work check permissions of `.amplify` folder',

errorName: 'FilePermissionsError',
classification: 'ERROR',
},
{
errorRegex: new RegExp(
`\\[ERR_MODULE_NOT_FOUND\\]:(.*)${this.multiLineEolRegex}|Error: Cannot find module (.*)`
Expand Down Expand Up @@ -220,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',
},
Expand Down
Loading