Send environment to render validation error instead of deployment (nil)
What does this MR do and why?
This fixes a bug in the deployment API, if you enter an invalid environment name, it will hang at render_validation_error!
, which we give the variable deployment
. deployment
does not exist until a few lines later. We also want to fail this on environment
errors. As an added bonus this will improve spec performance of ./spec/requests/api/deployments_spec.rb:192
by 5+ minutes
How to set up and validate locally
- Do an API call with an invalid environment name:
curl --header "PRIVATE-TOKEN: <private token>" -X POST --data "environment=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&sha=f15b32277d2c55c6c595845a87109b09c913c556&ref=master&tag=false&status=success" "http://gdk.test:3000/api/v4/projects/6/deployments"
. On the old code it will timeout after 5 minutes and send a 500 Internal Server Error. On the new code it will fail fast and still send a 500 error (with an error message explaining why it fails)
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #382547 (closed)
Edited by Roy Zwambag