Group validation fails incorrectly when descendants have permanent redirects

From https://gitlab.com/gitlab-org/gitlab-ce/issues/41786#note_53899101

Steps to reproduce

  • Create group 'foo'
  • Create subgroup 'foo/bar'
  • Rename group 'foo' to 'baz'
  • Notice subgroup now has permanent redirect 'foo/bar' => 'baz/bar'
  • Try to rename group 'baz' back to 'foo'
  • See validation error path 'foo' has been taken before

Expected behavior

  • Create group 'foo'
  • Create subgroup 'foo/bar'
  • Rename group 'foo' to 'baz'
  • Notice subgroup now has permanent redirect 'foo/bar' => 'baz/bar'
  • Rename group 'baz' back to 'foo'
  • Result:
    • 'baz' => 'foo'
    • 'baz/bar' => 'foo/bar'
    • Permanent redirects from 'foo' and 'foo/bar' are destroyed

It seems like we need conflicting_redirects_exists? to return false if the redirect sources are its own descendants.

If we do that, is it possible to break your own Git URLs?

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16397 fixes a specific case, but I think this issue is more general.

Edited Jan 11, 2018 by Michael Kozono
Assignee Loading
Time tracking Loading