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

Rapidjson assert on invalid vehicle syntax #418

Closed
jcoupey opened this issue Dec 15, 2020 · 0 comments · Fixed by #429
Closed

Rapidjson assert on invalid vehicle syntax #418

jcoupey opened this issue Dec 15, 2020 · 0 comments · Fixed by #429

Comments

@jcoupey
Copy link
Collaborator

jcoupey commented Dec 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant