A bad request will crash the function. Add parameter validation and catch exceptions so that valid responses can be returned.