Gracefully handle invalid states when filtering environments
What does this MR do and why?
This merge request handles Environments::EnvironmentsFinder::InvalidStatesError
exception gracefully to return a bad request (400) response instead of an internal server error (500) when trying to filter environments with an invalid states
value (allowed values are: available
and stopped
).
Fixes (#360138 (closed)).
How to set up and validate locally
- Start GDK locally, if it isn't up already:
gdk start
. - Make sure one of the projects on your local installation has an environment configured.
- In your terminal, send a request to the
/environments
endpoint (using your preferred method of API authentication) as follows:
echo -e | curl -v -X GET -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_TOKEN" localhost:3000/api/v4/projects/:project_id/environments?states=a
- Validate that the response has status
400
with the following error message:Requested states are invalid
.
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.
Edited by Ahmed Hemdan