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
geocodeWithOptions:completionHandler: crash on features unwrap #106
Comments
@ingalls @mattficke, are there any situations where the Geocoding API would return a non-FeatureCollection or a FeatureCollection that lacks a |
@1ec5 Not a valid reason no - On no results we simply return something like {
"type": "FeatureCollection",
"features": []
} If you run into someplace where this is not the case I would love to see the URL that generated it. |
@1ec5 not sure if this is relevant here, but batch queries to the permanent endpoint return an array of FeatureCollections. |
We do account for that difference in I’ve tried a number of possibilities but was unable to get the normal Geocoding API to return something that Swift couldn’t parse as a feature collection. If we remove the force-cast here, we’d still have to produce an error since it would be invalid data coming back from the API. (Optionally casting could obscure the error and cause an issue that’s more difficult to debug later.) |
@1ec5 We've pulled the code into our project manually, adjusted the code to avoid force-unwraps since we don't allow force-unwraps in our code base (except in rare cases), and invoke the completion blocks with a new "failed to parse json" error instead. |
That sounds like a good solution for this project. Please let us know if you continued to run into that error in the wild (with details about the request, if possible). |
The crash in #106 (comment) was fixed by the migration to Codable in #127: now a malformed GeoJSON response will cause the error handler to be invoked instead of crashing. Please open separate issues if you encounter another situation where this library crashes on malformed input. |
geocodeWithOptions:completionHandler:
in v0.6.1 can fail to force-unwrap the returned JSON feature collection —MBGeocoder.swift#L179
./cc @1ec5
The text was updated successfully, but these errors were encountered: