aws-amplify / aws-amplify/amplify-cli
Removing a category resource incorrectly handles the non existing ones
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/dev/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
v14.19.1
### Amplify CLI Version
9.2.0
### What operating system are you using?
macOS
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
no
### Amplify Categories
auth
### Amplify Commands
delete
### Describe the bug
Executing `amplify remove ` causes internal error if the category wasn't previously added.
### Expected behavior
Attempting to remove a resource that wasn't previously added should be properly handled and notify the Cx that a resource wasn't found and not crash the execution
### Reproduction steps
1. `amplify init`
2. `amplify remove auth --yes`
will error out with
```
🛑 Cannot convert undefined or null to object
TypeError: Cannot convert undefined or null to object
at Function.keys ()
at Object.run (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-auth/lib/commands/auth/remove.js:20:37)
at Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-auth/lib/index.js:340:25)
at /snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:159:47
at executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:11)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9)
at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:165:13)
```
### GraphQL schema(s)
```graphql
# Put schemas below this line
```
### Project Identifier
_No response_
### Log output
```
# Put your logs below this line
```
### Additional information
Note: this internal error only show up if I don't create any Auth before.
If I add an Auth, then delete twice, the 2nd delete will return a nicer error No resources added for this category
Contributor guide
Assessment
This issue has not been assessed yet.