Regular rules without approvers appearing on the merge request form and result in 500 error on submit
Sometimes we receive 500 error about any_approval rule uniqueness:
2020-04-09T15:46:13.168Z Completed 500 Internal Server Error in 267ms (ActiveRecord: 59.7ms | Elasticsearch: 0.0ms | Allocations: 71585)
2020-04-09T15:46:13.168Z
2020-04-09T15:46:13.168Z ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "any_approver_merge_request_rule_type_unique_index"
2020-04-09T15:46:13.168Z DETAIL: Key (merge_request_id, rule_type)=(123962, 4) already exists.
2020-04-09T15:46:13.168Z ):
2020-04-09T15:46:13.168Z
2020-04-09T15:46:13.168Z app/services/issuable_base_service.rb:171:in `block in create'
2020-04-09T15:46:13.168Z app/services/issuable_base_service.rb:170:in `create'
2020-04-09T15:46:13.168Z app/services/merge_requests/base_service.rb:50:in `create'
2020-04-09T15:46:13.168Z lib/gitlab/metrics/instrumentation.rb:161:in `block in create'
2020-04-09T15:46:13.168Z lib/gitlab/metrics/method_call.rb:36:in `measure'
2020-04-09T15:46:13.168Z lib/gitlab/metrics/instrumentation.rb:161:in `create'
2020-04-09T15:46:13.168Z app/services/merge_requests/create_service.rb:38:in `create'
2020-04-09T15:46:13.168Z lib/gitlab/metrics/instrumentation.rb:161:in `block in create'
2020-04-09T15:46:13.168Z lib/gitlab/metrics/method_call.rb:36:in `measure'
2020-04-09T15:46:13.168Z lib/gitlab/metrics/instrumentation.rb:161:in `create'
2020-04-09T15:46:13.168Z app/services/merge_requests/create_service.rb:13:in `execute'
2020-04-09T15:46:13.168Z lib/gitlab/metrics/instrumentation.rb:161:in `block in execute'
...
It happens because during invalid circumstances regular rules without approvers have been stored in the database.
Related issues:
Workaround
The invalid regular rules (without any groups or users) are displayed on the merge request form. Removing such rules resolves the issue and submitting the merge request continues without an exception
Edited by Igor Drozdov