Unable to set developer_can_initial_push and allow_force_push during group creation via API

Summary

This looks similar to a previous bug we've had: #468484 (closed). When creating a subgroup via the API on GitLab.com setting developer_can_initial_push and allow_force_push aren't honored. A subsequent PUT request is needed to set the attribute to true.

Steps to reproduce

  1. Create a group like this:
curl POST --location 'https://gitlab.com/api/v4/groups' \
--header 'PRIVATE-TOKEN: $TOKEN' \
--form 'name="test-group"' \
--form 'path="test-group"' \
--form 'parent_id="[group_id]"' \
--form 'default_branch_protection_defaults[developer_can_initial_push]="true"' \
--form 'default_branch_protection_defaults[allow_force_push]="true"' \
--form 'default_branch="main"'
  1. GET the created group. default_branch_protection_defaults[developer_can_initial_push]="true" isn't set
curl GET --header 'PRIVATE-TOKEN: $TOKEN' 'https://gitlab.com/api/v4/groups/[group_id]'
  1. PUT the value to the group
curl PUT --location 'https://gitlab.com/api/v4/groups/[group_id]' \
--header 'PRIVATE-TOKEN: $TOKEN' \
--form 'default_branch_protection_defaults[developer_can_initial_push]="true"'

Example Project

Subgroup: https://gitlab.com/ndesilva-gold/test-group-7

What is the current bug behavior?

default_branch_protection_defaults[developer_can_initial_push]="true" isn't honored during group creation via API.

What is the expected correct behavior?

Attribute should be set correctly during initial creation.

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

    (For installations with omnibus-gitlab package run and paste the output of: \\\\\\\\\\\\\\\`sudo gitlab-rake gitlab:env:info\\\\\\\\\\\\\\\`)  (For installations from source run and paste the output of: \\\\\\\\\\\\\\\`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production\\\\\\\\\\\\\\\`)     

Results of GitLab application Check

Expand for output related to the GitLab application check

   (For installations with omnibus-gitlab package run and paste the output of: \\\\\\\`sudo gitlab-rake gitlab:check SANITIZE=true\\\\\\\`)  (For installations from source run and paste the output of: \\\\\\\`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true\\\\\\\`)  (we will only investigate if the tests are passing)    

Possible fixes

Edited by 🤖 GitLab Bot 🤖