aws-amplify / aws-amplify/amplify-cli
[gen2-migration] Generated DynamoDB table mapping hardcodes the Gen1 env name for branchName with no validation
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
## Summary
When `generate` produces `amplify/data/resource.ts`, each `migratedAmplifyGen1DynamoDbTableMappings` entry's `branchName` is emitted as a hardcoded string literal of the Gen1 environment name. At runtime `@aws-amplify/backend-data` matches the mapping against the deploy branch (`process.env.AWS_BRANCH ?? "sandbox"`). If the generated literal is not manually edited to match the Gen2 deploy branch, the mapping does not apply and the affected models do not adopt the existing Gen1 tables.
## Details
- `packages/amplify-cli/src/commands/gen2-migration/generate/amplify/data/data.renderer.ts` (~L379) emits `branchName: ''` with only a code comment as guidance.
- The schema branch resolution uses `process.env.AWS_BRANCH ?? "sandbox"`; the two only align if the deploy branch equals the Gen1 env name or the user edits the literal.
- Nothing in the CLI validates or warns on a mismatch.
## Expected
Default the generated `branchName` to the actual deploy branch, and/or emit a validation warning or error at generate/deploy time when the mapping branch cannot match the deploy branch — rather than relying solely on a comment.
## Type
Bug / robustness
Contributor guide
Research direction
Start in packages/amplify-cli/src/commands/gen2-migration/generate/amplify/data/data.renderer.ts around line 379, then trace how generate and deploy resolve the branch name against process.env.AWS_BRANCH. Done means generated mappings no longer silently fail when the deploy branch differs from the Gen1 environment, with the agreed default or a clear validation warning or error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100