Send only required fields to protected environment

What does this MR do and why?

Send only required fields to protected environment

Only send name and updated rules instead of the entire environment. This fixes the issue for the environments containing deprecated fields.

References

Screenshots or screen recordings

Before After
Screen_Recording_2025-03-24_at_14.15.47 Screen_Recording_2025-03-24_at_14.16.25

How to set up and validate locally

  1. Visit Project -> Settings -> CI/CD -> Protected environments
  2. Protect an environment
  3. Using updateProtectedEnvironment update the environment adding required_approval_count property.
    The API would reject the update, to pass this, comment these blocks in the protected_environments.rb
if has_deprecated_approval_rules_params?
  unprocessable_entity!(s_("ProtectedEnvironment|Parameter 'required_approval_count' is deprecated and shouldn't be used. See https://gitlab.com/groups/gitlab-org/-/epics/9662"))
end
  1. After setting required_approval_count property restore the has_deprecated_approval_rules_params rules.
  2. Try adding new rules to the environment.
  3. Verify the PUT request to /api/v4/projects/<project_id>/protected_environments/<environment_name> contains only the environment name and the new rule.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Anna Vovchenko

Merge request reports

Loading