parcelvoy / platform

Parcelvoy: Open source multi-channel marketing automation platform. Send data-driven emails, sms, push notifications and more!
https://parcelvoy.com
MIT License
258 stars 47 forks source link

Failed to parse private key: Error: Invalid PEM formatted message. #474

Closed reaper closed 4 months ago

reaper commented 4 months ago

Hi, after upgrading to the version 1.7.0 and configuring the APN/Firebase provider, I reproduce an error reported on sentry after launching a campaign:

Failed to parse private key: Error: Invalid PEM formatted message.

/usr/src/app/build/providers/push/LocalPushProvider.js in LocalPushProvider.send at line 101:47

            apn: this.apn,
            fcm: this.fcm,
        }); // Types are not up to date
    }
    async send(push) {
        // TODO: Need a better way of bubbling up errors
        const { tokens, title, body, custom } = push;
-->     const response = await this.transport.send(typeof tokens === 'string' ? [tokens] : tokens, {
            title,
            topic: this.apn?.bundleId,
            body,
            custom,
        });
        const invalidTokens = [];
        for (const method of response) {

The FCM provider fields seem OK. I tried to modify the private key content without success.

pushchris commented 4 months ago

Just to see if my hunch is correct, can you try replacing new lines inside of your key with \n I wonder if somewhere along the process its not properly reading the PEM file

reaper commented 4 months ago

Just to see if my hunch is correct, can you try replacing new lines inside of your key with \n I wonder if somewhere along the process its not properly reading the PEM file

@pushchris I tried both, by default in the JSON payload, there are \n characters. I removed them but it didn't work