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

Amplify Pull Notification: MAC verified OK But 🛑 Failed to enable the APNS channel. #13517

Closed
jinglongwu opened this issue Jan 7, 2024 · 15 comments
Labels
bug Something isn't working notifications Issues tied to the notifications category

Comments

@jinglongwu
Copy link

Amplify CLI Version

12.10.0

Question

Hi, exactly like the closed one Issue #11916, I tried to pull an existing env, which we have been developing for ios in mac, in windows now for developing Android, I got the same error with Notification:

√ The certificate password (if any):  ·
MAC verified OK
× There was an error initializing your environment.
🛑 Failed to enable the APNS channel.

Here is the error.json, it is not so descriptive unfortunately.

{
    "name": "NotificationsChannelAPNSFault",
    "classification": "FAULT",
    "options": {
        "message": "Failed to enable the APNS channel."
    },
    "downstreamException": {
        "message": "Resource not found",
        "code": "NotFoundException",
        "[Message]": "See error.Message for details.",
        "time": "2024-01-07T22:51:14.982Z",
        "requestId": "88b86af3-589f-467f-ba97-ada798194368",
        "statusCode": 404,
        "retryable": false,
        "retryDelay": 31.504166553577573
    },
    "link": "https://docs.amplify.aws/cli/project/troubleshooting/"
}

Please help.

@jinglongwu jinglongwu added pending-triage Issue is pending triage question General question labels Jan 7, 2024
@jinglongwu
Copy link
Author

Looks like the code fails right here -

message: `Failed to enable the ${channelName} channel.`,

@ykethan
Copy link
Member

ykethan commented Jan 8, 2024

Hey @jinglongwu, could you try running the pull with --debug added and provide us the output. Additionally, could you provide us the Project Identifier output provided on the terminal or run amplify diagnose --send-report at the root of the project and provide us the output.
Tried reproducing the issue by creating a new project with notifications APNS enabled then in a new empty directory pull the environment but did not observe an error.

@ykethan ykethan added notifications Issues tied to the notifications category pending-response Issue is pending response from the issue author labels Jan 8, 2024
@jinglongwu
Copy link
Author

jinglongwu commented Jan 8, 2024

--debug output

$ amplify pull --appId xxxxx--envName dev --debug

Opening link: https://us-east-1.admin.amplifyapp.com/admin/xxxxx/dev/verify/?loginVersion=1
⠼ Confirm login in the browser or manually paste in your CLI login key:
Successfully received Amplify Studio tokens.
Amplify AppID found: xxxxx. Amplify App name is: xxxxx
Backend environment dev found in Amplify Console app: xxxxx
? Choose your default editor: Visual Studio Code
√ Choose the type of app that you're building · javascript
Please tell us about your project
? What javascript framework are you using react-native
? Source Directory Path:  src      
? Distribution Directory Path: /
? Build Command:  npm.cmd run-script build  
? Start Command: npm.cmd run-script start
Not pulling components because this project is not configured with the "react" framework.
? Do you plan on modifying this backend? Yes
| Fetching updates to backend environment: dev from the cloud.Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
/ Building resource api/xxxx
⚠️  WARNING: your GraphQL API currently allows public create, read, update, and delete access to all models via an API Key. To configure PRODUCTION-READY authorization rules
, review: https://docs.amplify.aws/cli/graphql/authorization-rules

/ Building resource api/xxxx✅ GraphQL schema compiled successfully.

Edit your schema at C:\Users\xxxx\workspace\xxx\xxxx\amplify\backend\api\xxxx\schema.graphql or place .graphql files in a directory at C:\Users\xxxx\workspace\xxxx\xxxxx\amplify\backend\api\xxxx\schema
Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
Overrides functionality is not implemented for this category
√ Successfully pulled backend environment dev from the cloud.
√ Select the authentication method for the APNS channel · Certificate
√ The certificate file path (.p12):  · Certificates.p12
√ The certificate password (if any):  · 
WARNING: can't open config file: c:/libressl/ssl/openssl.cnf
MAC verified OK
× There was an error initializing your environment.
🛑 Failed to enable the APNS channel.

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

NotificationsChannelAPNSFault: Failed to enable the APNS channel.
    at Object.enable (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\channel-apns.js:121:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async pushChanges (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\multi-env-manager.js:302:22)
    at async Object.initEnv (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\multi-env-manager.js:45:40)
    at async initEnv (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\index.js:47:5)

Resource not found
NotFoundException: Resource not found
    at Object.extractError (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\protocol\json.js:80:27)
    at Request.extractError (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\protocol\rest_json.js:61:8)
    at Request.callListeners (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:686:14)
    at Request.transition (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:688:12)
    at Request.callListeners (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
    at Request.emit (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:686:14)
    at Request.transition (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:688:12)
    at Request.callListeners (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
    at callNextListener (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:96:12)
    at IncomingMessage.onEnd (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\event_listeners.js:417:13)
    at IncomingMessage.emit (node:events:525:35)
    at IncomingMessage.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Session Identifier: aa1c03d1-2889-4a06-adc9-0d6759f075fb

✅ Report saved: C:\Users\xxxxx\AppData\Local\Temp\xxxx\report-1704752598757.zip

- Sending zip
File at path: 'C:\Users\xxxxx\workspace\xxx\xxxxx\amplify\backend\amplify-meta.json' does not exist
× Sending zip

amplify diagnose --send-report output

$ amplify diagnose --send-report

Learn more at https://docs.amplify.aws/cli/reference/diagnose/

✅ Report saved: C:\Users\xxx\AppData\Local\Temp\xxx\report-1704752807908.zip

- Sending zip
File at path: 'C:\Users\xxx\workspace\xxx\xxx\amplify\backend\amplify-meta.json' does not exist
× Sending zip
PS C:\Users\xxx\workspace\xxx\xxx> 

as you see i am not able to get it work on my Windows env as the initial pull failed. However i got project identifier from my MacOS - Project Identifier: d7b8e480892e2d65bb2e0c38058c9236

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

ykethan commented Jan 9, 2024

@jinglongwu thank you for the information. Wanted to check into some information, is the profile configured locally in the same region as pinpoint resource?
From the stack trace the SDK call on

data = await context.exeInfo.pinpointClient.updateApnsChannel(params).promise();
await context.exeInfo.pinpointClient.updateApnsSandboxChannel(sandboxParams).promise();
does appears to be throwing an error. The error occurs when the sdk call is unable to find the resource, Could you update the region on the profile and re-try the pull?
Additionally, could you verify if the pinpoint resource exists on the AWS console.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Jan 9, 2024
@jinglongwu
Copy link
Author

Hi @ykethan, this is an existing project that we have been developing in MacOS. In MacOS, we put the .aws/config and .aws/credentials into home directory ~. We are not only using AWS Pinpoints but also Cognito, dynamoDb, GraphQL etc. With that said, the profile exists, the region setting matches the deployment, and those services exist too.

Now, i am setting up my Windows to develop. What i did is to copy the same .aws to my home directory as

%USERPROFILE%\.aws\config

%USERPROFILE%\.aws\credentials

and i ran amplify pull. In the above output, we can see that it pulls every other resources (services) correctly but only the Notification fails.

I think if the profile and/or credentials was wrong, or the .aws was not copied to correct position, I would not be able to pull down anything in Windows environment. Please advise.

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

ykethan commented Jan 10, 2024

@jinglongwu thank you for the information. On revisiting the debug output noticed the message WARNING: can't open config file: c:/libressl/ssl/openssl.cnf.
tried producing the in a new app with APNS and then pull in different directory but did not observe this behaviour. I believe the error may be due to the SSL library being used on the windows terminal, let me try to reproduce this issue on a windows machine.
While i work on a reproduction steps, could check the version or library being used by running openssl version.
#12969 (comment)
additionally, could you try switching to LibreSSL as suggested in the comment and re-run the pull to verify if this mitigates the issue.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Jan 10, 2024
@jinglongwu
Copy link
Author

jinglongwu commented Jan 11, 2024

@ykethan I am aware of the openssl vs libressl issue in #12969 and i have switched to Libressl in order to get above output.

$ openssl version
WARNING: can't open config file: c:/libressl/ssl/openssl.cnf
LibreSSL 2.5.5

I installed Libressl via choco install libressl. link here - https://community.chocolatey.org/packages/libressl

By doing so, it doesn't create such c:/libressl/ssl/openssl.cnf.

Also I just realized that the LibreSSL version that i use is 2.5.5, which is the last version the library supports windows.

The trouble is that the project stopped creating a binary for windows at 2.5.5 as you can see here: https://ftp.openbsd.org/pub...

Are you sure my issue is openssl related? it was an warning and it says MAC verified OK so it seems the verification of .p12 file has completed.

Note that when i was using openssl, i also got similar output as in #12969. Because I have experienced this issue in MacOS, that's why i knew to use LibreSSL instead.

🛑 Command failed: openssl pkcs12 -in /Users/joakimrosenfeldtpedersen/Certificates.p12 -out /var/folders/cy/n2b5gjxj4dv1mztr65gpklgc0000gn/T/temp.pem -nodes -passin pass:
Error outputting keys and certificates
00DEF7DD01000000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:341:Global default library context, Algorithm (RC2-40-CBC : 0), Properties ()

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Jan 11, 2024
@jinglongwu
Copy link
Author

hmmm interestingly, i ran the same amplify pull today and got a different exception today - Missing required key 'ApplicationId' in params

√ Successfully pulled backend environment dev from the cloud.
√ Select the authentication method for the APNS channel · Certificate
√ The certificate file path (.p12):  · Certificates.p12
√ The certificate password (if any):  · 
WARNING: can't open config file: c:/libressl/ssl/openssl.cnf
MAC verified OK
× There was an error initializing your environment.
🛑 Failed to enable the APNS channel.

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

NotificationsChannelAPNSFault: Failed to enable the APNS channel.
    at Object.enable (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\channel-apns.js:121:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async pushChanges (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\multi-env-manager.js:302:22)
    at async Object.initEnv (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\multi-env-manager.js:45:40)
    at async initEnv (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\index.js:47:5)

Missing required key 'ApplicationId' in params
MissingRequiredParameter: Missing required key 'ApplicationId' in params
    at ParamValidator.fail (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\param_validator.js:50:37)
    at ParamValidator.validateStructure (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\param_validator.js:62:14)
    at ParamValidator.validateMember (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\param_validator.js:89:21)
    at ParamValidator.validate (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\param_validator.js:34:10)
    at Request.VALIDATE_PARAMETERS (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\event_listeners.js:166:42)
    at Request.callListeners (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at callNextListener (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:96:12)
    at C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\event_listeners.js:120:11
    at finish (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\config.js:396:7)
    at C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\config.js:414:9
    at Credentials.get (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\credentials.js:127:7)
    at getAsyncCredentials (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\config.js:408:24)
    at Config.getCredentials (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\config.js:428:9)
    at Request.VALIDATE_CREDENTIALS (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\event_listeners.js:111:28)
    at Request.callListeners (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:102:18)
    at Request.emit (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:686:14)
    at Request.transition (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at Request.runTo (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:406:15)
    at C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:795:12
    at new Promise (<anonymous>)
    at Request.promise (C:\snapshot\amplify-cli\build\node_modules\aws-sdk\lib\request.js:781:12)
    at Object.enable (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\channel-apns.js:115:79)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async pushChanges (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\multi-env-manager.js:302:22)
    at async Object.initEnv (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\multi-env-manager.js:45:40)
    at async initEnv (C:\snapshot\amplify-cli\build\node_modules\@aws-amplify\amplify-category-notifications\lib\index.js:47:5)

Session Identifier: b0fcd9b8-18e7-4976-a619-4b1718574d38

@jinglongwu
Copy link
Author

Okay I believe I got this issue resolved. The problem is about the line ending difference between Unix vs Windows. (aka LF vs CRLF).

Context
My git defaults to checkout the remote code (in LF) automatically converted to CRLF with default set up git config core.autocrlf true.

Solution
I removed my local git repo, then set git config core.autocrlf input, which will make git checking out the line breaking as it is. Now the newly cloned repo's line ending will be in LF because the repo was initialized in MacOS.

Checkout as-is, commit Unix-style

Git will not perform any conversion when checking out text files. When committing text files, CRLF will be converted to LF. For cross-platform projects this is the recommended setting on Unix ("core.autocrlf" is set to "input").

After so, I re-ran amplify pull --appId xxxxx--envName dev --debug and everything went through smoothly.

How I discover this
When I was blocked, I tried to do amplify init --appId xxxxx instead of amplify pull. The cli ran through but it messed up the line endings of everything in ./amplify/backend, which makes me realized that my local repo is checked out as CRLF while Amplify-CLI init/pull with LF.

So I re-cloned, and the issues is gone.

Working Theory
My guess is that the APNS resource, which was not found, probably has an id stored in some of the file, and the CRLF ending confused Amplify as it may expect LF ending. @ykethan you may try to reproduce by changing the ending of the file, where APNS is described, into CRLF and see whether you get the same "Resource not found"error.

@ykethan
Copy link
Member

ykethan commented Jan 11, 2024

@jinglongwu thank you for the information, marking this as bug.

@ykethan ykethan added bug Something isn't working and removed pending-triage Issue is pending triage question General question labels Jan 11, 2024
@dcolin
Copy link

dcolin commented Jan 24, 2024

Hi, i've got the same error message "🛑 Failed to enable the APNS channel."

I'm on MacOS, with Amplify CLI 12.0.1 and LibreSSL 3.8.2.

Capture d’écran 2024-01-24 à 11 27 08

@ykethan
Copy link
Member

ykethan commented Jan 24, 2024

@dcolin do could you provide us the Project Identifier(not the session identifier) that printed in the terminal? additionally, could you try running the cli command with the --debug flag and provide us the output.

@dcolin
Copy link

dcolin commented Jan 24, 2024

@ykethan i found the problem with --debug argument, i was using a sandbox certificate! Thanks for your help.

@ykethan
Copy link
Member

ykethan commented Jan 24, 2024

Closing the issue as this is cause by third party dependancy.

@ykethan ykethan closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2024
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

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.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working notifications Issues tied to the notifications category
Projects
None yet
Development

No branches or pull requests

3 participants