You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Internal Server Error when sending POST request to /route without specifying points #1995
curl -X POST -H "Content-type: application/json" -d "{}" http://localhost:8989/route
Error handling a request: 17a5bee0823f74d0
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
Ah, this has nothing to do with custom exception handling and mediatypes for once, but is a simple error.
In GH core, there's a check that checks that enough points are there, and it returns a GHResponse with an error (as is the convention there..) And it works when there are no CHs. (Like in the tests.)
But when there are CHs, we get an ArrayIndexOutOfBoundsException from somewhere where CH preconditions are checked.
I think we agree now that all validation should be in the web service, and if the library must do it again, then it can, but.. the web service should only pass valid requests to the library.
Maybe we should slowly start @Valid ating the GHRequest. Without changing anything in the core for now.
Or maybe (for RouteResource) indeed remove all the exceptions in the resource, and make sure all the exceptions in the core are thrown from the right place and as IllegalArgumentException.
I would check something like "point list may not be empty" in GraphHopper#route, because they need to be checked also when using GraphHopper without the resource. For GET we already do this in the resource and I would just move it into the GraphHopper class, see #1996.
In GH core, there's a check that checks that enough points are there, and it returns a GHResponse with an error (as is the convention there..) And it works when there are no CHs. (Like in the tests.)
Ugh its even more complicated than that: CH has to to be disabled and then there is this checkNonChMaxWaypointDistance check which causes the error, but this check only really runs if the max non ch distance is not set to default (Integer.MAX)...
Activity
michaz commentedon Apr 21, 2020
Ah, this has nothing to do with custom exception handling and mediatypes for once, but is a simple error.
In GH core, there's a check that checks that enough points are there, and it returns a GHResponse with an error (as is the convention there..) And it works when there are no CHs. (Like in the tests.)
But when there are CHs, we get an ArrayIndexOutOfBoundsException from somewhere where CH preconditions are checked.
michaz commentedon Apr 21, 2020
I think we agree now that all validation should be in the web service, and if the library must do it again, then it can, but.. the web service should only pass valid requests to the library.Maybe we should slowly start @Valid ating the GHRequest. Without changing anything in the core for now.michaz commentedon Apr 21, 2020
... with the slight complication that validation annotations don't work with Mixins of course, because Mixins are Jackson and this is Hibernate >:-(
michaz commentedon Apr 21, 2020
Or maybe (for RouteResource) indeed remove all the exceptions in the resource, and make sure all the exceptions in the core are thrown from the right place and as IllegalArgumentException.
No idea.
easbar commentedon Apr 21, 2020
I would check something like "point list may not be empty" in
GraphHopper#route, because they need to be checked also when usingGraphHopperwithout the resource. For GET we already do this in the resource and I would just move it into the GraphHopper class, see #1996.easbar commentedon Apr 21, 2020
Ugh its even more complicated than that: CH has to to be disabled and then there is this
checkNonChMaxWaypointDistancecheck which causes the error, but this check only really runs if the max non ch distance is not set to default (Integer.MAX)...easbar commentedon Apr 21, 2020
I fixed this in #2010