When parsing the vehicles array in the json input, we loop over vehicles and use check_id which throws whenever encountering a non-object (e.g. a string). As a result, this kind of input is normally handled as an input error:
{
"vehicles": [
{
"id": 1,
"capacity": [14],
...
},
"foo"
],
...
}
Now the fun fact is that if we exchange order for the first two values in vehicles, we hit a Rapidjson assert related to "foo" not being an object.
This is due to an earlier call to get_amount_size which tries to access the capacity value without prior check for having a valid json object.
Extra bonus fixing point: inline get_amount_size and get rid of the loop on vehicles, it's not necessary because we enforce amount size consistency down the line when adding vehicles/jobs.
When parsing the
vehiclesarray in the json input, we loop over vehicles and usecheck_idwhich throws whenever encountering a non-object (e.g. a string). As a result, this kind of input is normally handled as an input error:Now the fun fact is that if we exchange order for the first two values in
vehicles, we hit a Rapidjson assert related to"foo"not being an object.This is due to an earlier call to
get_amount_sizewhich tries to access thecapacityvalue without prior check for having a valid json object.Extra bonus fixing point: inline
get_amount_sizeand get rid of the loop onvehicles, it's not necessary because we enforce amount size consistency down the line when adding vehicles/jobs.