Creating a new project using the REST api fails to create a non-empty repo most of the time.

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

I'm having issues creating a project initialized with a readme. I'm using the REST API. 30% of the time, the request succeeds in creating a project with a readme. 70% of the time, it creates an empty gitlab project.

Steps to reproduce

  • create an access token with all of the scopes selected
  • send an API request that looks like this (here is an example with fetch, using javascript): fetch('https://gitlab.com/api/v4/projects/', { method: 'POST', headers: {"Private-Token": "<ACCESS TOKEN>", "Content-Type": "application/json"}, body: JSON.stringify({'initialize_with_readme': true, 'name': 'niolegitlab1047', 'description': 'new project', 'namespace_id': 8669482}) }).then(x => x.json()).then(x => console.log(x))
  • then visit the new project using your web browser
  • notice that it usually will not have a README or any files, even though initialize_with_readme is true
  • notice that sometimes it will have a README

Example Project

here is a project that should not be empty: https://gitlab.com/rfqa/niolegitlab2036 here is a project that is not empty: https://gitlab.com/rfqa/niolegitlab2034

Both projects above where requested to be initialized with a readme. A readme was created for one, but not the other.

What is the current bug behavior?

REST API requests to the create project endpoint do not always create projects that have been initialized with a README, even though initialize_with_readme has been set in the body with the value true.

What is the expected correct behavior?

REST API requests to create a project with a readme already initialized, i.e. initialize_with_readme is true in the body of the request, should always have a README file initialized.

Relevant logs and/or screenshots

Screen_Shot_2022-08-29_at_2.29.00_PM

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

git lab server version:

  • gitlab.com, it is GitLab Enterprise Edition 15.4.0-pre c85d1375
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 🤖