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

New APNS feature cannot handle empty environment variables #2173

Closed
vulpicastor opened this issue Mar 17, 2021 · 2 comments · Fixed by #2174
Closed

New APNS feature cannot handle empty environment variables #2173

vulpicastor opened this issue Mar 17, 2021 · 2 comments · Fixed by #2174

Comments

@vulpicastor
Copy link
Contributor

Expected Behavior

Pull request #2077 added the feature of using Apple Push Notification Services, but unfortunately it doesn't seem to handle the case where APNS environment variables are not set gracefully. The program should check that the variables are non-empty before passing to node-apn for configuration.

Current Behavior

The program crashes with an error in node-apn.

Steps to Reproduce

Run npm run test:notification without setting the APNS environment variables.

Environment

  • OS: Fedora 33
  • Version at commit 10f7e0c
# ** All configuration variables are optional **
# Copy this file and name it as `dotenv` (without backticks)
# Read https://jef.codes/streetmerchant/getting-started/#customization for help on customizing this file
########################################################################################################

ASCII_BANNER=
ASCII_COLOR=
APNSAUTHKEY=
APNSBUNDLEID=
APNSDEVICETOKEN=
APNSKEYID=
APSPRODUCTION=
APNSTEAMID=
AUTO_ADD_TO_CART=
BROWSER_TRUSTED=
DESKTOP_NOTIFICATIONS=
DISCORD_NOTIFY_GROUP=[redacted]
DISCORD_NOTIFY_GROUP_3060=
DISCORD_NOTIFY_GROUP_3060TI=
DISCORD_NOTIFY_GROUP_3070=
DISCORD_NOTIFY_GROUP_3080=
DISCORD_NOTIFY_GROUP_3090=
DISCORD_NOTIFY_GROUP_CORSAIR_SF=
DISCORD_NOTIFY_GROUP_RX6800=
DISCORD_NOTIFY_GROUP_RX6800XT=
DISCORD_NOTIFY_GROUP_RX6900XT=
DISCORD_NOTIFY_GROUP_RYZEN5600=
DISCORD_NOTIFY_GROUP_RYZEN5800=
DISCORD_NOTIFY_GROUP_RYZEN5900=
DISCORD_NOTIFY_GROUP_RYZEN5950=
DISCORD_NOTIFY_GROUP_SONYPS5C=
DISCORD_NOTIFY_GROUP_SONYPS5DE=
DISCORD_NOTIFY_GROUP_XBOXSX=
DISCORD_NOTIFY_GROUP_XBOXSS=
DISCORD_NOTIFY_GROUP_TEST=
DISCORD_WEB_HOOK=[redacted]
EMAIL_PASSWORD=
EMAIL_TO=
EMAIL_USERNAME=
HEADLESS=
IN_STOCK_WAIT_TIME=300
LOG_LEVEL=
LOW_BANDWIDTH=
MAX_PRICE_SERIES_3060=
MAX_PRICE_SERIES_3060TI=
MAX_PRICE_SERIES_3070=
MAX_PRICE_SERIES_3080=
MAX_PRICE_SERIES_3090=
MAX_PRICE_SERIES_CORSAIR_SF=
MAX_PRICE_SERIES_RX6800=
MAX_PRICE_SERIES_RX6800XT=
MAX_PRICE_SERIES_RX6900XT=
MAX_PRICE_SERIES_RYZEN5600=
MAX_PRICE_SERIES_RYZEN5800=
MAX_PRICE_SERIES_RYZEN5900=550
MAX_PRICE_SERIES_RYZEN5950=800
MAX_PRICE_SERIES_SONYPS5C=
MAX_PRICE_SERIES_SONYPS5DE=
MAX_PRICE_SERIES_XBOXSS=
MAX_PRICE_SERIES_XBOXSX=
MAX_PRICE_SERIES_TEST=
MICROCENTER_LOCATION=[redacted]
MQTT_BROKER_ADDRESS=
MQTT_BROKER_PORT=
MQTT_CLIENT_ID=
MQTT_PASSWORD=
MQTT_QOS=
MQTT_TOPIC=
MQTT_USERNAME=
OPEN_BROWSER=
PAGE_BACKOFF_MIN=60000
PAGE_BACKOFF_MAX=7200000
PAGE_SLEEP_MIN=60000
PAGE_SLEEP_MAX=300000
PAGE_TIMEOUT=
PAGERDUTY_INTEGRATION_KEY=
PAGERDUTY_SEVERITY=
PHILIPS_HUE_API_KEY=
PHILIPS_HUE_CLOUD_ACCESS_TOKEN=
PHILIPS_HUE_CLOUD_CLIENT_ID=
PHILIPS_HUE_CLOUD_CLIENT_SECRET=
PHILIPS_HUE_CLOUD_REFRESH_TOKEN=
PHILIPS_HUE_LAN_BRIDGE_IP=
PHILIPS_HUE_LIGHT_COLOR=
PHILIPS_HUE_LIGHT_IDS=
PHILIPS_HUE_LIGHT_PATTERN=
PHONE_CARRIER=
PHONE_NUMBER=
PLAY_SOUND=
PROXY_ADDRESS=
PROXY_PROTOCOL=
PROXY_PORT=
PUSHBULLET=
PUSHOVER_EXPIRE=
PUSHOVER_RETRY=
PUSHOVER_TOKEN=
PUSHOVER_USER=
PUSHOVER_PRIORITY=
RESTART_TIME=
SCREENSHOT=
SHOW_ONLY_BRANDS=
SHOW_ONLY_MODELS=
SHOW_ONLY_SERIES=ryzen5900,ryzen5950
SLACK_CHANNEL=
SLACK_TOKEN=
SMARTTHINGS_TOKEN=
SMARTTHINGS_SWITCH_LABEL=
SMTP_ADDRESS=
SMTP_PORT=
STORES=amazon,amd,bestbuy,bandh,officedepot,microcenter,target,walmart
TELEGRAM_ACCESS_TOKEN=
TELEGRAM_CHAT_ID=
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_FROM_NUMBER=
TWILIO_TO_NUMBER=
TWITCH_ACCESS_TOKEN=
TWITCH_CHANNEL=
TWITCH_CLIENT_ID=
TWITCH_CLIENT_SECRET=
TWITCH_REFRESH_TOKEN=
TWITTER_ACCESS_TOKEN_KEY=
TWITTER_ACCESS_TOKEN_SECRET=
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_TWEET_TAGS=
STREAMLABS_ACCESS_TOKEN=
STREAMLABS_TYPE=
STREAMLABS_IMAGE=
STREAMLABS_SOUND=
STREAMLABS_DURATION=
WEB_PORT=9000

Logs

streetmerchant/node_modules/@parse/node-apn/lib/config.js:81
    throw new Error("token.keyId is missing");
    ^

Error: token.keyId is missing
    at validateToken (streetmerchant/node_modules/@parse/node-apn/lib/config.js:81:11)
    at validateOptions (streetmerchant/node_modules/@parse/node-apn/lib/config.js:71:9)
    at config (streetmerchant/node_modules/@parse/node-apn/lib/config.js:34:5)
    at new Client (streetmerchant/node_modules/@parse/node-apn/lib/client.js:26:19)
    at new Provider (streetmerchant/node_modules/@parse/node-apn/lib/provider.js:12:19)
    at Object.sendApns (streetmerchant/build/src/notification/apns.js:36:25)
    at Object.sendNotification (streetmerchant/build/src/notification/notification.js:30:12)
    at Object.<anonymous> (streetmerchant/build/test/functional/test-notification.js:32:16)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
@vulpicastor
Copy link
Contributor Author

There are several typos in my dotenv where there should be an underscore in the APNS variables. Correcting them gives the same runtime error.

@jef
Copy link
Owner

jef commented Mar 19, 2021

Fixed by 99a274d

@jef jef closed this as completed Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants