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

Crash in alert parsing when there is no "expires" defined #47

Closed
katylinn opened this issue Feb 6, 2017 · 2 comments
Closed

Crash in alert parsing when there is no "expires" defined #47

katylinn opened this issue Feb 6, 2017 · 2 comments

Comments

@katylinn
Copy link

katylinn commented Feb 6, 2017

I'm getting a crash at line 35 in Alert.swift

The code assumes that the "expires" property is required, but the documentation says its an optional.

expires optional
The UNIX time at which the alert will expire. (Some alerts sources, unfortunately, do not define expiration time, and in these cases this parameter will not be defined.)

https://darksky.net/dev/docs/response

There is currently an alert with no "expire" property at Whistler, but because alerts are temporary in nature, the I'm sure the repro won't last:
https://api.darksky.net/forecast/[key]/50.1149639,-122.9486474

"alerts": [ { "title": "Snowfall Warning", "regions": [ "Sunshine Coast" ], "severity": "warning", "time": 1486412460, "description": "Bands of snow rotating around a low pressure system off the coast will continue to stream across southern Vancouver Island, the Sunshine Coast and the Lower Mainland today. Snowfall amounts across these regions will vary widely depending on the location and intensity of the individual bands. Local amounts of 5 cm or more are likely. Be prepared to adjust your driving with changing road conditions. Visibility may be suddenly reduced at times in heavy snow. Please continue to monitor alerts and forecasts issued by Environment Canada. To report severe weather, send an email to ec.tempetepacifique-pacificstorm.ec@canada.ca or tweet reports to #BCStorm.", "uri": "https://weather.gc.ca/warnings/report_e.html?bc38" } ]

@sxg
Copy link
Owner

sxg commented Feb 7, 2017

Hey, thanks for letting me know! The fix is pretty straightforward, and I'll be releasing it later tonight (hopefully). It looks like the Dark Sky API added and changed a number of things recently. I'll incorporate breaking changes ASAP in the new release, and I'll add compatibility for new features in a release shortly after that.

@sxg
Copy link
Owner

sxg commented Feb 7, 2017

This issue is fixed in version 4.0.0. I'll be taking a more thorough look at the API changes with Dark Sky sometime soon, and I'll release version 4.1.0 that'll support the changes.

@sxg sxg closed this as completed Feb 7, 2017
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

No branches or pull requests

2 participants