project create API: calls with both 'import_url' and '"initialize_with_readme": "true"' now fail
Summary
A customer reported that after upgrading from 14.3 to 14.9 API calls that the used to create projects had stopped working, failing with:
"import_error": "Unable to save project. Error: 5:GetRepoPath: not a git repository: \"/var/opt/gitlab/git-data/repositories/@hashed/73/47/73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049.git\".",
The path referred to is the one that would have been created for this new project.
From their logs, I noticed they were passing initialize_with_readme": "true"
as well as an HTTPS import url "import_url": "https://user:token@gitlab.example.com/templates/someproject.git"
Setting initialize_with_readme
to false resolved this. I tested this on 13.12, and confirmed their finding that this used to work OK.
I suspect some other change in the application has caused this combination of parameters to fail, whereas before import_url
would take precedent over initialize_with_readme
.
Alternatively, there's a race condition here, and the action that fails because of Error: 5:GetRepoPath: not a git repository
sometimes gets delayed while the project is created in parallel.
GitLab team members can read more in the ticket.
Documentation revised
!85782 (merged) raised to document this issue.
Steps to reproduce
-
This has been verified on GitLab 16.6.1
-
Populate token and hostname for the two
curl
callscat > glhn << EOF gitlab.example.com EOF cat > token << EOF myaccesstoken EOF
-
Create a project via import, specifying initialize_with_readme as false
- specify a valid group ID in
namespace_id=133
curl --request POST \ --header "PRIVATE-TOKEN: $(cat token)" \ --form "name=repro$(date '+%s')" \ --form "description=reproduce proj creation issue 360266" \ --form "namespace_id=133" \ --form "initialize_with_readme=false" \ --form "import_url=https://gitlab.com/gitlab-com/support/toolbox/gitlab-smoke-tests.git" \ "https://$(cat glhn)/api/v4/projects/" | jq .
- specify a valid group ID in
-
Create a project via import, specifying initialize_with_readme as true
- specify a valid group ID in
namespace_id=133
curl --request POST \ --header "PRIVATE-TOKEN: $(cat token)" \ --form "name=repro$(date '+%s')" \ --form "description=reproduce proj creation issue 360266" \ --form "namespace_id=133" \ --form "initialize_with_readme=true" \ --form "import_url=https://gitlab.com/gitlab-com/support/toolbox/gitlab-smoke-tests.git" \ "https://$(cat glhn)/api/v4/projects/" | jq .
Fails with:
"import_type": "git", "import_status": "none", "import_error": "Unable to save project. Error: 5:repository not found.",
- specify a valid group ID in
When I opened this issue, I verified that both [2] and [3] would be successful on 13.12 - so this used to work.
What is the current bug behavior?
It's reasonable that initialize_with_readme
and import_url
are mutually exclusive, because it's then ambiguous whether it should be an emptyish project or an imported one.
But this should be picked up by validation. The parameters should not get passed to the back end and fail for an arbitrary reason.
Validation does happen - if true
or false
isn't passed:
{
"error": "initialize_with_readme is invalid"
}
Project gets created; Rails thinks the repository got created, and so doesn't render the correct "create your repository" screen
What is the expected correct behavior?
Validate the supplied parameters.
Output of checks
Results of GitLab environment info
14.9.1, 16.6.1
Possible fixes
We should not support both of this params simultaneously. It should be one or the other.