-
Notifications
You must be signed in to change notification settings - Fork 119
Description
Bug Description
The GBFS parser crashes when a station returns a negative count in vehicle_types_available, causing the entire feed to be skipped. This completely breaks routing for the affected provider.
Error
[GBFS] error processing feed villo (https://api.cyclocity.fr/contracts/bruxelles/gbfs/v3/gbfs.json): not exact
[boost.json:27 at /deps/boost/boost/json/value.hpp:1700:9 in function
'typename std::enable_if<(std::is_arithmetic<_Tp>::value && (! std::is_same<T, bool>::value)), T>::type
boost::json::value::to_number(boost::system::error_code&) const']
Root Cause
In src/gbfs/parser.cc (~line 308), the count field from vehicle_types_available is parsed with to_number<unsigned>(). The Villo/JCDecaux Brussels GBFS feed (both v2 and v3) has station_id 123 returning:
{
"station_id": "123",
"vehicle_types_available": [
{ "vehicle_type_id": "mechanical", "count": -1 },
{ "vehicle_type_id": "electrical", "count": 2 }
],
...
}The count: -1 fails boost::json's unsigned conversion (i >= 0 check fails → error::not_exact), and since there's no per-station error handling in load_station_status(), the exception aborts the entire feed.
Feed URLs (both affected)
- v2:
https://api.cyclocity.fr/contracts/bruxelles/gbfs/gbfs.json - v3:
https://api.cyclocity.fr/contracts/bruxelles/gbfs/v3/gbfs.json
Suggested Fix
Use the non-throwing overload with error_code and skip/clamp invalid values per-station, similar to how load_station_information handles individual station errors:
boost::system::error_code ec;
auto const count = vt.at("count").to_number<unsigned>(ec);
if (ec) continue; // or clamp to 0Alternatively, wrap each station's parsing in load_station_status() with a try-catch to skip malformed stations instead of aborting the entire feed.
Environment
- motis
masterbranch (Docker imageghcr.io/motis-project/motis:master) - Feed provider: JCDecaux/Cyclocity (Villo! Brussels)