aws-amplify / aws-amplify/amplify-cli
update/delete of notifications on newly created environment yields in errors
- 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
12.10.1
### 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 manual changes made
### Describe the bug
I have created a new environment names 'staging' add Auth, Function, Analytics and Notifications (pinpoint APNS for now ) that was successful .
i did `amplify env add` and named the new one prod everything was success except for notification
When i run `amplify status` all resources shows 'No Change' but Notifications shows 'Create' ,
When i run `amplify add notification` or `amplify update notification` and selected the channel as APNS or FCM it yields the following error
```$ amplify add notification --debug
✔ Choose the notification channel to enable · APNS | Apple Push Notifications
🛑 Cannot read properties of undefined (reading 'replace')
Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
UnknownFault: Cannot read properties of undefined (reading 'replace')
at genericErrorToAmplifyException (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/amplify-exception-handler.js:126:49)
at handleException (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/amplify-exception-handler.js:27:28)
at process. (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:52:93)
at process.emit (node:events:513:28)
at process._fatalException (node:internal/process/execution:149:25)
Cannot read properties of undefined (reading 'replace')
TypeError: Cannot read properties of undefined (reading 'replace')
at PinpointName.extractResourceName (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/pinpoint-name.js:7:82)
at scanCategoryMetaForPinpoint (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/pinpoint-helper.js:296:80)
at getPinpointAppStatusNotifications (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/pinpoint-helper.js:101:51)
at getPinpointAppStatus (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/pinpoint-helper.js:122:84)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ensurePinpointApp (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/pinpoint-helper.js:206:45)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/commands/notifications/add.js:44:114)
at async Object.executeAmplifyCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/index.js:62:5)
at async executePluginModuleCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)
at async executeCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)
Session Identifier: 7669723c-81f1-4f41-85a5-81ff7c53c221
✅ Report saved: /var/folders/s0/mnwl9h99021dvthf1w0hz9tr0000gn/T/elovuMOMsApp/report-1715595641860.zip
✔ Done
Project Identifier: 30c6d7ea108cb6bcc4017c50672ccfd5
```
I just recognised Pinpoint is not available on us-west-1 but my staging env was also configured on us-west-1
### Expected behavior
Should be able to update certs for APNS and FCM and amplify push to use resources.
### Reproduction steps
1. Create a environment from existing environment and do amplify push.
### Project Identifier
Project Identifier: 30c6d7ea108cb6bcc4017c50672ccfd5
### Log output
```
# Put your logs below this line
2024-05-13T10:06:42.781Z|error : Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'replace')
ProjectInitFault: Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'replace')
2024-05-13T10:06:49.562Z|info : amplify pull core {"debug":true,"yes":false}
2024-05-13T10:06:49.615Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
2024-05-13T10:06:52.909Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["elovu-us-west-1-production"])
2024-05-13T10:06:52.911Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"region":"us-west-1"}])
2024-05-13T10:06:52.912Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileCredentials(["elovu-us-west-1-production"])
2024-05-13T10:06:52.937Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["elovu-us-west-1-production"])
2024-05-13T10:06:52.938Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"region":"us-west-1"}])
2024-05-13T10:06:52.939Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileCredentials(["elovu-us-west-1-production"])
2024-05-13T10:06:52.946Z|info : amplify-provider-awscloudformation.zip-util.downloadZip.s3.getFile([{"Key":"[***]rent-[***]ud-[***]d.zip"},null])
2024-05-13T10:06:52.948Z|info : amplify-provider-awscloudformation.aws-s3.s3.getFile([{"Key":"[***]rent-[***]ud-[***]d.zip","Bucket":"[***]ify-[***]msapp-[***]od-[***]942-[***]ment"}])
2024-05-13T10:06:54.719Z|info : amplify-provider-awscloudformation.initialize-env.run.cfn.updateamplifyMetaFileWithStackOutputs([{"StackName":"[***]ify-[***]msapp-[***]od-[***]942"}])
2024-05-13T10:06:54.726Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["elovu-us-west-1-production"])
2024-05-13T10:06:54.732Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"region":"us-west-1"}])
2024-05-13T10:06:54.732Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileCredentials(["elovu-us-west-1-production"])
2024-05-13T10:06:54.811Z|info : amplify-provider-awscloudformation.aws-cfn.updateamplifyMetaFileWithStackOutputs.cfn.listStackResources([{"StackName":"[***]ify-[***]msapp-[***]od-[***]942"}])
2024-05-13T10:06:56.403Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]ify-[***]msapp-[***]od-[***]942"}])
2024-05-13T10:06:58.380Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:us-[***]st-[***]40:stack/[***]ify-[***]msapp-[***]od-[***]942-[***]mLambdaStack-[***]4NTPWD/[***]a8c0-[***]0d-[***]ef-[***]57-[***]ee943"}])
2024-05-13T10:06:58.388Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:us-[***]st-[***]40:stack/[***]ify-[***]msapp-[***]od-[***]942-[***]vumomsapp-[***]4967H/[***]94c0-[***]0d-[***]ef-[***]31-[***]cbc79"}])
2024-05-13T10:06:58.392Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:us-[***]st-[***]40:stack/[***]ify-[***]msapp-[***]od-[***]942-[***]sAuth-[***]RMKO6/[***]cf50-[***]0d-[***]ef-[***]61-[***]0fc3b"}])
2024-05-13T10:06:58.394Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:us-[***]st-[***]40:stack/[***]ify-[***]msapp-[***]od-[***]942-[***]olGroups-[***]D8C6YF/[***]5190-[***]0d-[***]ef-[***]5c-[***]69d89"}])
2024-05-13T10:06:58.397Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:us-[***]st-[***]40:stack/[***]ify-[***]msapp-[***]od-[***]942-[***]tConfirmation-[***]X7QMLK/[***]72c0-[***]0d-[***]ef-[***]02-[***]2448f"}])
2024-05-13T10:07:00.249Z|info : amplify-provider-awscloudformation.aws-s3.s3.getFile([{"Key":"[***]ify-[***]json","Bucket":"[***]ify-[***]msapp-[***]od-[***]942-[***]ment"}])
2024-05-13T10:07:01.565Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["elovu-us-west-1-production"])
2024-05-13T10:07:01.568Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"region":"us-west-1"}])
2024-05-13T10:07:01.568Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileCredentials(["elovu-us-west-1-production"])
2024-05-13T10:07:05.230Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileConfig(["elovu-us-west-1-production"])
2024-05-13T10:07:05.232Z|info : amplify-provider-awscloudformation.system-config-manager.getProfiledAwsConfig.profileConfig([{"region":"us-west-1"}])
2024-05-13T10:07:05.232Z|info : amplify-provider-awscloudformation.system-config-manager.getProfileCredentials(["elovu-us-west-1-production"])
2024-05-13T10:07:05.240Z|info : amplify-provider-awscloudformation.CognitoUserPoolService.listUserPool.cognito.listUserPools([{"params":{"MaxResults":60}}])
2024-05-13T10:07:06.187Z|info : amplify-provider-awscloudformation.CognitoUserPoolService.listUserPoolIdentityProviders.cognito.listIdentityProviders([{"UserPoolId":"[***]s-[***]st-[***]JafQk","MaxResults":60}])
2024-05-13T10:07:07.845Z|error : Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'replace')
ProjectInitFault: Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'replace')
2024-05-13T10:08:33.475Z|info : amplify help core Analytics
2024-05-13T10:08:49.002Z|info : amplify remove analytics
2024-05-13T10:08:49.079Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
2024-05-13T10:08:53.830Z|error : Analytics resource elovumomsapp is being used by the notifications category and cannot be removed
ResourceInUseError: Analytics resource elovumomsapp is being used by the notifications category and cannot be removed
2024-05-13T10:09:08.095Z|info : amplify remove notifications
2024-05-13T10:09:08.171Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
2024-05-13T10:09:17.764Z|error : Cannot read properties of undefined (reading 'replace')
UnknownFault: Cannot read properties of undefined (reading 'replace')
2024-05-13T10:09:24.276Z|info : amplify remove notifications {"force":true,"yes":false}
2024-05-13T10:09:24.355Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
2024-05-13T10:09:30.690Z|error : Cannot read properties of undefined (reading 'replace')
UnknownFault: Cannot read properties of undefined (reading 'replace')
2024-05-13T10:16:00.316Z|info : amplify add notification
2024-05-13T10:16:00.395Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
2024-05-13T10:16:06.302Z|error : Cannot read properties of undefined (reading 'replace')
UnknownFault: Cannot read properties of undefined (reading 'replace')
2024-05-13T10:17:24.570Z|info : amplify version core
2024-05-13T10:20:37.909Z|info : amplify add notification {"debug":true,"yes":false}
2024-05-13T10:20:37.988Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
2024-05-13T10:20:44.929Z|error : Cannot read properties of undefined (reading 'replace')
UnknownFault: Cannot read properties of undefined (reading 'replace')
2024-05-13T10:23:39.185Z|info : amplify diagnose core {"send-report":true,"yes":false}
2024-05-13T10:23:39.263Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
```
### 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 by tracing PinpointName.extractResourceName in amplify-category-notifications/pinpoint-name.js and its callers in pinpoint-helper.js, especially during the notifications add, update, and remove commands. Reproduce the environment-copy flow with amplify status and notification commands; done means APNS or FCM notification operations no longer fail with the undefined replace error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100