Skip to content

Fix update of optional_approvals in bot comment

Martin Čavoj requested to merge 420948-fix-optional-approvals-change into master

What does this MR do and why?

This change fixes a policy bot comment message in existing MRs in case the policy changes from having optional approvals to having required approvals

How to set up and validate locally

  1. Create a policy which sets approvals_required: 0. Example YAML:
    type: scan_result_policy
    name: Secrets
    description: ''
    enabled: true
    rules:
      - type: scan_finding
        scanners:
          - secret_detection
        vulnerabilities_allowed: 0
        severity_levels: []
        vulnerability_states: []
        branch_type: protected
    actions:
      - type: require_approval
        approvals_required: 0
        user_approvers_ids:
          - 1
  2. Create MR that violated the policy
  3. Observe a bot comment that has optional_approvals section
  4. Update the policy to set approvals_required: 1
  5. Verify that bot comment message in the MR changes and optional_approvals section is removed

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #420948 (closed)

Merge request reports