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
- Visit Project -> Settings -> CI/CD -> Protected environments
- Protect an environment
- Using
updateProtectedEnvironmentupdate the environment addingrequired_approval_countproperty.
The API would reject the update, to pass this, comment these blocks in theprotected_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
- After setting
required_approval_countproperty restore thehas_deprecated_approval_rules_paramsrules. - Try adding new rules to the environment.
- Verify the
PUTrequest 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