Fix ArgumentError in ProjectApprovalRules API
What does this MR do and why?
Contributes to #455241 (closed)
Problem
REST API is missing a validaton for the list of allowed report_type
values. When a user provides an unsupported value, the application
returns a 500 error.
Solution
Use values
to restrict the list of allowed values.
How to set up and validate locally
- Try to create a project approval rule with a wrong
report_type
:
url --request POST --header "PRIVATE-TOKEN: <PRIVATE_TOKEN>" --header "Content-Type: application/json" --data '{"name": "test", "approvals_required": 0, "report_type": "wrong"}' "http://gdk.test:3000/api/v4/projects/3/approval_rules"
- You should receive an error
{"error":"report_type does not have a valid value"}
- Before the fix, the application returns an Internal error:
{"message":"500 Internal Server Error"}
Numbered steps to set up and validate the change are strongly suggested.
Edited by Vasilii Iakliushin