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

Conversation

ShadowCat567
Copy link
Contributor

Problem

Error like EPERM: operation not permitted, rename 'C:\Users\[...]\.amplify\artifacts\cdk.out\synth.lock.45040_1' → 'C:\Users\[...]\.amplify\artifacts\cdk.out\synth.lock' not mapped properly.
Updated The stack named _stackName_ is in a failed state. You may need to delete it from the AWS console : DELETE_FAILED resolution message to suggest looking at original error message, has additional info about cause of error.

Issue number, if available: N/A

Changes

Handles errors like EPERM: operation not permitted, rename 'C:\Users\[...]\.amplify\artifacts\cdk.out\synth.lock.45040_1' → 'C:\Users\[...]\.amplify\artifacts\cdk.out\synth.lock'.

Checklist

  • If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
  • If this PR requires a change to the Project Architecture README, I have included that update in this PR.
  • If this PR requires a docs update, I have linked to that docs PR above.
  • If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the run-e2e label set.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: 1234ebb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/backend-deployer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -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

@ShadowCat567 ShadowCat567 marked this pull request as ready for review December 3, 2024 23:24
@ShadowCat567 ShadowCat567 requested a review from a team as a code owner December 3, 2024 23:24
@@ -184,6 +184,15 @@ export class CdkErrorMapper {
errorName: 'FilePermissionsError',
classification: 'ERROR',
},
{
errorRegex:
/EPERM: operation not permitted, rename (?<fileName>.*) → 'C:(.*)synth.lock(.*)/,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/EPERM: operation not permitted, rename (?<fileName>.*) → 'C:(.*)synth.lock(.*)/,
/EPERM: operation not permitted, rename (?<fileName>(.*)\/synth\.lock\.\S+) → '(.*)\/synth\.lock'/,

So that:

  1. We can drop C: letter (what if project is on D:?)
  2. File name capture is more precise.
  3. Dots are special characters in regex, escaped them.
  4. Do we need trailing (.*) ?

Comment on lines 191 to 192
resolutionMessage:
'Check that you have the right permissions to rename this file and try running the command again',
Copy link
Member

Choose a reason for hiding this comment

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

These EPERM on Windows are likely related to concurrent access.
See https://www.google.com/search?q=eperm+windows+concurrent+access+to+file&rlz=1C5GCCM_en&oq=eperm+windows+concurrent+access+to+file&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCDY2NjRqMGo3qAIAsAIA&sourceid=chrome&ie=UTF-8 .

it could be permissions but it's more likely concurrent access and simple re-try may resolve it.

Could you please update the message to convey that possibility?

sobolk
sobolk previously approved these changes Dec 4, 2024
/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',

@ShadowCat567 ShadowCat567 merged commit 6015595 into aws-amplify:main Dec 4, 2024
40 checks passed
@ShadowCat567 ShadowCat567 deleted the EPERM-synth-lock branch December 4, 2024 17:28
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.

3 participants