Unable to remove user owner when group is owner

Summary

It used to be that a group could have another group as owner without any direct user member as owner. With new groups this is not possible anymore.

Steps to reproduce

  1. Create a group.
  2. Create a new group and add the first group as owner.
  3. Remove user member from the second group.

GitLab will then complain that it is not allowed to remove the last owner without assigning a new owner.

This used to be possible and I cannot find any documentation regarding the fact that this changed, so I'm assuming it is a regression.

Results of GitLab environment info

Expand for output related to GitLab environment info

System information
System:		Ubuntu 22.04
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	3.0.6p216
Gem Version:	3.4.19
Bundler Version:2.4.20
Rake Version:	13.0.6
Redis Version:	7.0.13
Sidekiq Version:6.5.7
Go Version:	unknown

GitLab information
Version:	16.5.0-ee
Revision:	fc87c9d4cca
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	13.11
URL:		https://selfhostedurl
HTTP Clone URL:	https://selfhostedurl/some-group/some-project.git
SSH Clone URL:	git@selfhostedurl:some-group/some-project.git
Elasticsearch:	no
Geo:		no
Using LDAP:	yes
Using Omniauth:	yes
Omniauth Providers: 

GitLab Shell
Version:	14.29.0
Repository storages:
- default: 	unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell

Gitaly
- default Address: 	unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version: 	16.5.0
- default Git Version: 	2.42.0

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.29.0 ? ... OK (14.29.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 100 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Database config exists? ... yes Tables are truncated? ... skipped All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 11/2 ... yes 52/4 ... yes 6/8 ... yes 6/9 ... yes 9/11 ... yes 9/13 ... yes 11/14 ... yes 11/15 ... yes 11/16 ... yes 9/22 ... yes 9/24 ... yes 4/27 ... yes 11/28 ... yes 11/29 ... yes 4/32 ... yes 9/33 ... yes 11/34 ... yes 6/35 ... yes 52/36 ... yes 11/39 ... yes 50/40 ... yes 18/47 ... yes 6/49 ... yes 4/51 ... yes 6/52 ... yes 6/55 ... yes 6/56 ... yes 4/59 ... yes 6/60 ... yes 6/74 ... yes 6/75 ... yes 22/80 ... yes 16/81 ... yes 16/82 ... yes 11/106 ... yes 28/107 ... yes 28/108 ... yes 4/115 ... yes 18/116 ... yes 11/131 ... yes 50/134 ... yes 18/135 ... yes 18/137 ... yes 18/138 ... yes 18/139 ... yes 29/140 ... yes 6/141 ... yes 6/142 ... yes 24/144 ... yes 17/148 ... yes 4/149 ... yes 18/150 ... yes 6/153 ... yes 43/154 ... yes 39/155 ... yes 50/156 ... yes 52/157 ... yes 39/159 ... yes 4/160 ... yes 29/161 ... yes 4/162 ... yes 46/164 ... yes 11/165 ... yes 11/166 ... yes 6/167 ... yes 21/168 ... yes 4/169 ... yes 18/170 ... yes 21/173 ... yes 41/174 ... yes 113/175 ... yes 21/178 ... yes 39/179 ... yes 17/181 ... yes 18/182 ... yes 61/183 ... yes 61/184 ... yes 39/185 ... yes 39/186 ... yes 6/187 ... yes 50/188 ... yes 18/194 ... yes 39/197 ... yes 39/199 ... yes 61/201 ... yes 39/202 ... yes 50/203 ... yes 39/211 ... yes 39/212 ... yes 29/216 ... yes 4/217 ... yes 11/218 ... yes 11/219 ... yes 4/221 ... yes 61/222 ... yes 21/223 ... yes 21/224 ... yes 113/225 ... yes 111/226 ... yes 117/227 ... yes 117/228 ... yes 39/229 ... yes 117/230 ... yes 117/231 ... yes 11/232 ... yes 39/233 ... yes 117/234 ... yes 39/236 ... yes 21/237 ... yes 21/238 ... yes 247/239 ... yes 4/240 ... yes 111/241 ... yes 61/243 ... yes 61/244 ... yes 117/245 ... yes 52/246 ... yes 52/247 ... yes 4/248 ... yes 11/250 ... yes 11/251 ... yes 19/252 ... yes 247/253 ... yes 6/254 ... yes 271/255 ... yes 271/257 ... yes 271/258 ... yes 18/259 ... yes 277/260 ... yes 247/261 ... yes 247/262 ... yes 50/263 ... yes 4/264 ... yes 6/265 ... yes 18/266 ... yes 277/267 ... yes 277/268 ... yes 277/269 ... yes 293/271 ... yes 293/272 ... yes 293/273 ... yes 293/274 ... yes 293/275 ... yes 18/276 ... yes 6/277 ... yes 11/278 ... yes 61/279 ... yes 6/280 ... yes 11/281 ... yes 11/282 ... yes 6/283 ... yes 39/285 ... yes 6/286 ... yes 6/287 ... yes 61/289 ... yes 4/290 ... yes 50/291 ... yes 61/292 ... yes 266/293 ... yes 39/294 ... yes 61/295 ... yes 11/297 ... yes 329/298 ... yes 335/299 ... yes 335/300 ... yes 6/301 ... yes 340/302 ... yes 340/303 ... yes 340/304 ... yes 52/305 ... yes 346/307 ... yes 6/308 ... yes 11/309 ... yes 329/310 ... yes 6/311 ... yes 334/312 ... yes 360/313 ... yes 329/314 ... yes 364/315 ... yes 367/317 ... yes 367/318 ... yes 329/319 ... yes 313/320 ... yes 313/321 ... yes 313/322 ... yes 313/323 ... yes 313/324 ... yes 313/325 ... yes 313/326 ... yes 313/327 ... yes 313/328 ... yes 313/329 ... yes 344/330 ... yes 6/333 ... yes 346/334 ... yes 6/336 ... yes 6/337 ... yes 346/338 ... yes 75/339 ... yes 346/340 ... yes 61/341 ... yes 329/343 ... yes 398/344 ... yes 398/345 ... yes 407/348 ... yes 409/349 ... yes 411/350 ... yes 405/351 ... yes 407/352 ... yes 409/353 ... yes 411/354 ... yes 418/355 ... yes 418/356 ... yes 421/357 ... yes 364/359 ... yes 39/360 ... yes 421/361 ... yes 364/362 ... yes 405/363 ... yes 407/364 ... yes 409/365 ... yes 411/366 ... yes 11/367 ... yes 11/369 ... yes 364/370 ... yes 405/371 ... yes 313/372 ... yes 313/373 ... yes 313/374 ... yes 334/375 ... yes 61/376 ... yes 75/377 ... yes 446/378 ... yes 446/379 ... yes 446/380 ... yes 446/381 ... yes 446/382 ... yes 346/383 ... yes 346/384 ... yes 458/385 ... yes 418/386 ... yes 458/387 ... yes Redis version >= 6.0.0? ... yes Ruby version >= 3.0.6 ? ... yes (3.0.6) Git user has default SSH configuration? ... yes Active users: ... 63 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled) All migrations must be finished before doing a major upgrade ... skipped (Advanced Search is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished