aws-amplify / aws-amplify/amplify-cli

(gen2-migration) `extractCategory()` uses fragile substring matching that can misclassify resources

Open Beginner friendly
#14,609 1 comment 0 reactions 0 assignees View on GitHub
gen2-migration
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### How did you install the Amplify CLI?

_No response_

### If applicable, what version of Node.js are you using?

_No response_

### Amplify CLI Version

0.4.0

### What operating system are you using?

Mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

### Describe the bug

`extractCategory()` in amplify-cli/src/commands/gen2-migration/categories.ts uses `.includes()` to determine the Amplify category from a CloudFormation logical resource ID. This is order-dependent and prone to false matches. Misclassification could cause resources to be displayed under the wrong category in the user-facing table.

For ex., a storage resource named `"authbackup"` has logical ID `"storageauthbackup"`. `extractCategory("storageauthbackup")` returns `"Auth"` instead of `"Storage"` because `"auth"` is checked first and `"storageauthbackup".includes("auth")` is true.

### Expected behavior

`extractCategory("storageauthbackup")` should return `"Storage"`

### Reproduction steps

1. Create a Gen1 app with `amplify add storage` and name the resource something containing auth
2. Run `amplify push` to deploy
3. Run `amplify gen2-migration decommission`
4. Observe the stateful resources table: the storage resource is listed under Auth instead of Storage

### Project Identifier

_No response_

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

### Before submitting, please confirm:

- [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.

Contributor guide

Open the contributing guide

Research direction

Start in amplify-cli/src/commands/gen2-migration/categories.ts and inspect extractCategory(), focusing on how logical resource IDs are matched to categories. Reproduce the reported storageauthbackup case through the gen2-migration decommission flow and verify that the resource appears under Storage rather than Auth.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.