Fix #599

Close #599

1. Now we catch the error and return a 400, which is the appropriate response.
2. Handle one legitimate case of a query with a recursive plan.