Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to amplify env checkout prod with failure retrieving In-App messaging and Email Channel #13653

Closed
2 tasks done
ericowhadi opened this issue Mar 15, 2024 · 20 comments
Closed
2 tasks done
Labels
notifications Issues tied to the notifications category pending-triage Issue is pending triage

Comments

@ericowhadi
Copy link

How did you install the Amplify CLI?

npm

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

20.10.0

Amplify CLI Version

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

when I initially did a amplify env checkout prod, I was prompted for a serverKey. By the time I checked for the serverKey, my Mac hung and I had to reboot it. Re-running amplify env checkout prod, this time all resources made it, the command was successfull, but I was not prompted for a serverKey. I looked at console, and did see that FCM channel was not configured in PinPoint, so I manually enabled FCM and assigned the serverKey from pinpoint console.
Then amplify env checkout dev, then came back to amplify env checkout prod and getting complain.

Describe the bug

when I initially did a amplify env checkout prod, I was prompted for a serverKey. By the time I checked for the serverKey, my Mac hung and I had to reboot it. Re-running amplify env checkout prod, this time all resources made it, the command was successfull, but I was not prompted for a serverKey. I looked at console, and did see that FCM channel was not configured in PinPoint, so I manually enabled FCM and assigned the serverKey from pinpoint console.
Then amplify env checkout dev, then came back to amplify env checkout prod and getting complain.
this is what I see when I do amplify env checkout dev:
✔ Initialized provider successfully.

✔ Successfully retrieved channel information for FCM.

✔ Channel information retrieved for In-App Messaging

Deployment state saved successfully.

✅ Initialized your environment successfully.

but when I do amplify env checkout prod:
✔ Initialized provider successfully.

✔ Successfully retrieved channel information for FCM.

⠋ Retrieving channel information for In-App Messaging.⠋ Retrieving channel information for Email.✖ There was an error initializing your environment.

🛑 Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'Id')

Resolution: Review the error message and stack trace for additional information.

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

⠙ Retrieving channel information for Email.

Session Identifier: 403cf9dd-5f13-4002-a614-c1964291d918

✅ Report saved: /var/folders/qd/g556jpdn0r114qsj2prqqrqc0000gn/T/pyxiscontribute/report-1710525021753.zip

✔ Done

Expected behavior

should succeed amplify env checkout prod

Reproduction steps

I don't know, I am in this stuck state and don't know what caused it in the first place.

Project Identifier

c9dd6cbc5e466a59de093a48bd94c543

Log output

# Put your logs below this line
2024-03-15T15:02:50.384Z|error : Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'Id')
ProjectInitFault: Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'Id')

Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@ericowhadi ericowhadi added the pending-triage Issue is pending triage label Mar 15, 2024
@ykethan
Copy link
Member

ykethan commented Mar 15, 2024

Hey @ericowhadi, thank you for reaching out. could you add --debug to the env checkout and provide us the output.
Could you try pulling the backend into a new empty directory outside your existing project directory, does this throw a similar error message and re-prompt for serverKey?

@ykethan ykethan added notifications Issues tied to the notifications category pending-response Issue is pending response from the issue author labels Mar 15, 2024
@ericowhadi
Copy link
Author

✔ Initialized provider successfully.

✔ Successfully retrieved channel information for FCM.

⠋ Retrieving channel information for In-App Messaging.⠋ Retrieving channel information for Email.✖ There was an error initializing your environment.

🛑 Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'Id')

Resolution: Review the error message and stack trace for additional information.

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

ProjectInitFault: Could not initialize categories for 'prod': Cannot read properties of undefined (reading 'Id')

at initializeEnv (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/initialize-env.js:122:19)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/commands/env/checkout.js:48:5)

at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/commands/env.js:52:13)

at async Object.executeAmplifyCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:194:9)

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)

Cannot read properties of undefined (reading 'Id')

TypeError: Cannot read properties of undefined (reading 'Id')

at getNotificationsAppListMeta (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/notifications-amplify-meta-api.js:148:58)

at getNotificationsAppMeta (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/notifications-amplify-meta-api.js:47:44)

at Object.pull (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/channel-in-app-msg.js:104:98)

at /snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-notifications/lib/notifications-manager.js:112:51

at /snapshot/amplify-cli/build/node_modules/promise-sequential/index.js:16:18

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

⠙ Retrieving channel information for Email.

Session Identifier: dc6bac4c-6b6e-47cf-bb64-97ce9da3a966

✅ Report saved: /var/folders/qd/g556jpdn0r114qsj2prqqrqc0000gn/T/pyxiscontribute/report-1710537220958.zip

✔ Done

Project Identifier: c9dd6cbc5e466a59de093a48bd94c543

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 15, 2024
@ericowhadi
Copy link
Author

"Could you try pulling the backend into a new empty directory outside your existing project directory, does this throw a similar error message and re-prompt for serverKey?"
I am not sure what I need to do? amplify pull? from dev env or prod env (from an empty directory located where (if I do it outside my project, how is amplify knows what project to pull from?)? since I cannot successfully amplify env checkout prod, not sure how I can amplify pull prod?
BTW thanks you very much for your very fast response, much appreciated.

@ykethan
Copy link
Member

ykethan commented Mar 15, 2024

hey, thank you for the information. we can pull the backend by running amplify pull --appId <app-id> --envName prod as I wanted to ensure if this was due to the failed prompt which may have not hydrated your files from the reboot that occurred on your PC.

additionally, in your team-provider-info.json do you observe analytics and notifications block with an id variable? if no could you try adding the block under the prod env as follows then run amplify env checkout prod to hydrate the meta file.

"analytics": {
        "nextapphost": {},
        "Pinpoint": {
          "Name": "xxxx",
          "Id": "xxxx",
          "Region": "us-east-1"
        }
      },
      "notifications": {
        "Pinpoint": {
          "Name": "xxxx",
          "Id": "xxxx",
          "Region": "us-east-1"
        }
      }

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Mar 15, 2024
@ericowhadi
Copy link
Author

OK, so the amplify pull in an new directory fails with a similar error: Cannot read properties of undefined (reading "Id"). And it did not prompt me for a serverKey. (note that the serverKey was manually added to pinpoint, so I guess it is not surprising that it does not ask for it again?).
As for team-provider-info.json, it already had the correct entries for the prod section. Both prod and dev have correct entries, with no missing id.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 18, 2024
@ykethan
Copy link
Member

ykethan commented Mar 21, 2024

@ericowhadi thank you for the information. To ensure could you check the amplify-meta.json present under the amplify/backend. the file should contain the analytics and notifications blocks with the structure similar to as follows

"analytics": {
    "nextapphost": {
      "providerPlugin": "awscloudformation",
      "service": "Pinpoint",
      "output": {
        "appName": "xxxx",
        "Region": "us-east-1",
        "Id": "xxxx"
      },
      "lastPushTimeStamp": "",
      "providerMetadata": {
        "s3TemplateURL": "xxxx",
        "logicalId": "xxxx"
      }
    }
  },
"notifications": {
    "nextapphost": {
      "Id": "xxxx",
      "ResourceName": "xxxx",
      "Name": "xxxx",
      "service": "Pinpoint",
      "output": {
        "Id": "xxxx",
        "Name": "xxxx",
        "Region": "us-east-1",
        "FCM": {
          "ApplicationId": "xxxx",
          "CreationDate": "2024-03-21T14:58:43.798Z",
          "DefaultAuthenticationMethod": "KEY",
          "Enabled": false,
          "HasCredential": true,
          "HasFcmServiceCredentials": false,
          "Id": "gcm",
          "IsArchived": false,
          "LastModifiedDate": "2024-03-21T14:59:20.885Z",
          "Platform": "GCM",
          "Version": 2
        },
        "InAppMessaging": {
          "Enabled": true,
          "ApplicationId": "xxxx",
          "Name": "xxxx"
        },
        "regulatedResourceName": "xxxx"
      },
      "lastPushTimeStamp": "2024-03-21T14:59:12.561Z"
    }

could you ensure if the id's are filled in and matched the pinpoint resource. if not run amplify env checkout prod
to hydrate the meta file. do note the meta file may be hidden in Vscode, under the .vscode/settings.json file.

additionally, could you try downloading the #current-cloud-backend.zip from the s3 deployment bucket amplify-<app-name>-<env-name>-<random-number>-deployment and check the amplify-meta.json.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Mar 21, 2024
@ericowhadi
Copy link
Author

@yketha after doing amplify env checkout prod (that fails obviously, since this is the bug I am having), the amplify-meta.json is indeed bogus for the notifications section but correct on analytics:
"notifications": {
"pyxiscontribute": {
"channels": [
"FCM",
"InAppMessaging"
],
"service": "Pinpoint"
}
}

while the dev environment have all data correctly populated for both analytics and pinpoint.
Reading your comment, I am under the impression that you suggest doing an amplify env checkout prod to hydrate the file and fix the problem. However, it does hydrate the file but with the problem in it.
as for the amplify-meta.json included in the #current-cloud-backend.zip inside the prod deployment bucket, it is also bogus and contain:
"notifications": {
"pyxiscontribute": {
"channels": [
"FCM",
"InAppMessaging"
],
"service": "Pinpoint"
}
}
instead of a fully populated notifications section.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 21, 2024
@ykethan
Copy link
Member

ykethan commented Mar 22, 2024

@ericowhadi could you provide us the team-provider-info.json via email to [email protected]?

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Mar 22, 2024
@ericowhadi
Copy link
Author

@ykethan just sent it.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 22, 2024
@ykethan
Copy link
Member

ykethan commented Mar 22, 2024

@ericowhadi thank you for the information. Did not notice any inconsistencies with the team-provider-info.json.
could you try running amplify update notifications and reselecting FCM which should prompt you to enter the Server key, then run amplify push this should update the amplify-meta.json.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Mar 22, 2024
@ericowhadi
Copy link
Author

@ykethan I did amplify env checkout prod
then from this bogus state, I did amplify update notifications
But this triggered a similar error "Cannot read properties of undefined (reading 'Id')". So it did not prompt me for anything and just failed the command.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 25, 2024
@ykethan
Copy link
Member

ykethan commented Mar 25, 2024

@ericowhadi interesting, could you try removing the notifications resource by amplify remove notification and then re-add it?
if the above does not mitigate the issue, would you be open for quick chat on a discord DM. my discord handle is ykethan

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Mar 25, 2024
@ericowhadi
Copy link
Author

If I do amplify remove notification, I am not sure I understand if this will remove it from both dev and prod. If I first do a amplify env checkout prod, then amplify remove notification, it will not remove it from dev, or will it?

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 26, 2024
@ykethan
Copy link
Member

ykethan commented Mar 26, 2024

@ericowhadi could you zip and provide us the amplify folder at [email protected], this would enable us to dive into the resources before making changes to backend?

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Mar 26, 2024
@ericowhadi
Copy link
Author

@ykethan sure I just did. Thank you for the support. Sent both dev and prod in case you need "working" vs "broken"

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 27, 2024
@ykethan
Copy link
Member

ykethan commented Mar 27, 2024

@ericowhadi thank you for sending the files. I was able to recreate the issue by modifying the amplify-meta.json in my project.
To mitigate the issue:

  1. download the #current-cloud-backend.zip from your project deployment bucket from AWS S3 console. The bucket name should have a pattern amplify-<project-name>-prod-<random-number>-deployment.
  2. extract and open amplify-meta.json.
  3. in file remove the notifications block and save.
  4. re-zip the contents of current-cloud-backend folder. Note, when re-zipping do ensure you are not zipping it as nested folder but rather only the contents.
  5. upload the zip to the S3 bucket.
  6. run amplify env checkout prod, this should prompt you for the server key and re-generate the notifications block in amplify-meta.json

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Mar 27, 2024
@ericowhadi
Copy link
Author

awesome, let me try

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Mar 27, 2024
@ericowhadi
Copy link
Author

great, it worked. It did not ask me for server key, I guess because I already had manually populated it. It coorectly hydrated the notifications section, and successfully checkout prod. However when pushing, I got a graphql updating issue, but that is another story and I will open a new bug on it. Thanks a million for the great support @ykethan

@ericowhadi
Copy link
Author

for the story, I found a workaround to the graphql issue that was having hard time updating a table where I changed pk, and had an index on. The solution was to first delete the table, push, then add the modified table. Amplify did not like doing it all at once.
Closing this issue any, and thanks again @ykethan, it is such a great experience to be supported, even on a corner case issue that was caused by a crash of my PC in the middle of a amplify update notifications...

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notifications Issues tied to the notifications category pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

2 participants