aws-amplify / aws-amplify/amplify-cli
gen2-migration Generating gen2 code fails when Cognito resource has custom attributes
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
v24.11.0
### Amplify CLI Version
14.5.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.
I did not
### Describe the bug
I started the migration from my old Gen1 backend to the new Gen2 version.
I have followed this documentation:
https://docs.amplify.aws/react/start/migrate-to-gen2/migrate-existing-app/
I am stuck at step 3, as the **amplify gen2-migration generate --skip-validations** command throws the following error:
🛑 Failed: SyntaxError: ',' expected. (20:43)
18 | email: "email",
19 | custom: {
> 20 | custom:family_name: "family_name",
| ^
21 | custom:given_name: "given_name",
22 | username: "sub"
23 | }
🛑 Rollback is not supported for the generate step.
### Expected behavior
The resource should be generated even if I have custom attributes set in my cognito resource.
### Reproduction steps
1. Have an amplify environment with a cognito auth resource that has custom attributes
2. Start the migration as the attached document describes the process.
3. Stuck at step 3, generation is failing.
### Project Identifier
_No response_
### Log output
```
# Put your logs below this line
⚠️ WARNING: AWS Amplify Gen 1 CLI is in maintenance mode and will reach end of life on May 1, 2027.
During maintenance mode, only critical bug fixes and security patches will be provided.
Migrate to Amplify Gen 2: https://docs.amplify.aws/react/start/migrate-to-gen2/
→ Planning complete
You are about to execute 'generate' on environment 'xxx/develop'.
Operations Summary
Resource: api/xxx (AppSync)
1. Generate amplify/data/resource.ts
Resource: auth/xxx (Cognito)
1. Generate amplify/auth/resource.ts
Project
1. Generate amplify/backend.ts
2. Update package.json with Gen2 dependencies
3. Generate amplify/package.json
4. Generate amplify/tsconfig.json
5. Generate amplify.yml
6. Update .gitignore with Gen2 entries
Implications
• Your local 'amplify/' directory will be replaced with Gen2 code
• Your root 'package.json' will be updated with Gen2 dependencies
(You can rollback this command by running: 'amplify gen2-migration generate --rollback')
⚠️ This command is in developer preview. For more information, visit https://docs.amplify.aws/react/start/migrate-to-gen2
✔ Do you want to continue? (y/N) · yes
[2026-06-22T13:59:52.009Z] [generate] [xxx/develop] • Execute
[2026-06-22T13:59:52.011Z] [generate] [xxx/develop] • Rendering data/resource.ts
[2026-06-22T13:59:52.360Z] [generate] [xxx/develop] • Rendering auth/resource.ts
🛑 Failed: SyntaxError: ',' expected. (20:43)
18 | email: "email",
19 | custom: {
> 20 | custom:family_name: "family_name",
| ^
21 | custom:given_name: "given_name",
22 | username: "sub"
23 | }
🛑 Rollback is not supported for the generate step.
Resolution: To restore your local directory to its previous state, use git to discard the changes.
Then restore the Amplify configuration by running: 'amplify pull --appId xxx --envName xxx'
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
```
### 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
Research direction
Start with the amplify gen2-migration generate --skip-validations command and the rendering step for amplify/auth/resource.ts described in the log. Reproduce with a Cognito resource containing custom attributes, then verify that generation produces valid TypeScript for the custom attribute names without the reported syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- authentication, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100