Skip to content

Fix ArgumentError in ProjectApprovalRules API

Vasilii Iakliushin requested to merge 455241_fix_report_type_error into master

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

  1. 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"
  1. You should receive an error {"error":"report_type does not have a valid value"}
  2. 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

Merge request reports