Cannot delete folder from the repository

Summary

A repository tree contains ghost folders that cannot be deleted.

Steps to reproduce

  1. Create an empty file in the folder (folder/empty)
  2. Delete the file empty
  3. You should still see a folder in the repository file tree. But it must be missing as the folder doesn't contain any files in it.

Example Project

https://gitlab.com/vyaklushin/my-test-project

https://gitlab.com/api/v4/projects/vyaklushin%2Fmy-test-project/repository/tree?ref=c26328137ccaaf62612a52e93aa2c9ffa3c8beb2&recursive=true&pagination=none

What is the current bug behavior?

A folder without any content is not deleted

What is the expected correct behavior?

A folder should not be present in the repository

Relevant logs and/or screenshots

Screenshot_2023-07-21_at_15.32.01

Screenshot_2023-07-21_at_15.32.06

Output of checks

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