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

fix: remove error incorrectly swallowed (fixes #13030) #13041

Merged
merged 7 commits into from
Aug 8, 2023

Conversation

jhockett
Copy link
Contributor

@jhockett jhockett commented Jul 31, 2023

Description of changes

Ensure Amplify exceptions are not swallowed during resource removal. This was causing confusing error messages being shown when running amplify remove <category>.

Current experience:

⚠️ 
You have configured resources that might depend on this Cognito resource.  Updating this Cognito resource could have unintended side effects.

Only one option for [Choose the resource you would want to remove]. Selecting [myAuth].

? Are you sure you want to unlink this imported resource from this Amplify backend environment? The imported resource itself will not be deleted
. Yes
ResourceRemoveFault: An error occurred when removing the resources from the local directory
    at AmplifyToolkit.removeResource (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/remove-resource.js:73:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-auth/lib/commands/auth/remove.js:21:26)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-auth/lib/index.js:346:5)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)
🛑 There was an error removing the auth resource

New error message:

⚠️ 
You have configured resources that might depend on this Cognito resource.  Updating this Cognito resource could have unintended side effects.

Only one option for [Choose the resource you would want to remove]. Selecting [myAuth].

? Are you sure you want to unlink this imported resource from this Amplify backend environment? The imported resource itself will not be deleted
. Yes
🛑 Resource cannot be removed because it has a dependency on another resource
Dependency: AppSync - myApi. Remove the dependency first.

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

Issue #, if available

Fixes #13030

Description of how you validated changes

Manual testing, yarn test

Checklist

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

@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2023

Codecov Report

Merging #13041 (0f5e057) into dev (ec9a2ba) will increase coverage by 48.45%.
Report is 287 commits behind head on dev.
The diff coverage is 60.60%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##              dev   #13041       +/-   ##
===========================================
+ Coverage    0.00%   48.45%   +48.45%     
===========================================
  Files        1296      842      -454     
  Lines      149743    38035   -111708     
  Branches     1296     7790     +6494     
===========================================
+ Hits            0    18430    +18430     
+ Misses     148447    18014   -130433     
- Partials     1296     1591      +295     
Files Changed Coverage Δ
...rmation/auth-stack-builder/auth-stack-transform.ts 91.30% <0.00%> (+91.30%) ⬆️
...tack-builder/auth-user-pool-group-stack-builder.ts 51.72% <ø> (+51.72%) ⬆️
...h-stack-builder/user-pool-group-stack-transform.ts 94.59% <0.00%> (+94.59%) ⬆️
.../src/provider-utils/awscloudformation/constants.ts 100.00% <ø> (+100.00%) ⬆️
...e-walkthrough-types/awsCognito-user-input-types.ts 100.00% <ø> (+100.00%) ⬆️
...vice-walkthrough-types/cognito-user-input-types.ts 100.00% <ø> (+100.00%) ⬆️
...y-category-function/src/commands/function/build.ts 0.00% <0.00%> (ø)
...ify-category-function/src/events/prePushHandler.ts 33.33% <0.00%> (+33.33%) ⬆️
...ider-utils/awscloudformation/utils/layerHelpers.ts 21.80% <0.00%> (+21.80%) ⬆️
...er-utils/awscloudformation/utils/storeResources.ts 30.38% <ø> (+30.38%) ⬆️
... and 57 more

... and 1244 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jhockett jhockett force-pushed the remove-err-msg-fix branch from 74e3f5d to 3229dd5 Compare August 1, 2023 18:20
@jhockett jhockett marked this pull request as ready for review August 1, 2023 20:46
@jhockett jhockett requested a review from a team as a code owner August 1, 2023 20:46
@@ -156,7 +156,7 @@ describe('remove-resource', () => {
},
serviceSuffix: { Lambda: '(function)', LambdaLayer: '(layer)' },
}),
).rejects.toThrowError('An error occurred when removing the resources from the local directory');
).rejects.toThrowError('Resource cannot be removed because it has a dependency on another resource');
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also assert on the type of the error since that's usually the culprit for these issues

@jhockett jhockett marked this pull request as draft August 2, 2023 19:25
Amplifiyer
Amplifiyer previously approved these changes Aug 2, 2023
@jhockett jhockett marked this pull request as ready for review August 3, 2023 00:08
Amplifiyer
Amplifiyer previously approved these changes Aug 7, 2023
@jhockett jhockett merged commit 2941584 into aws-amplify:dev Aug 8, 2023
@jhockett jhockett deleted the remove-err-msg-fix branch August 8, 2023 18:23
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.

An error occurred when removing the resources from the local directory
4 participants