New issues cannot be created in imported projects
Description
- When attempting to create an issue via the API, users receive a 409 error with the message "Duplicated issue".
- When trying to create an issue through the UI, users encounter a generic 500 error.
Environment
The affected project was imported from a project with existing issues.
Impacted offerings:
- GitLab.com
- GitLab Dedicated
- GitLab Self-Managed
Workaround
The issue internal ID needs to be updated to a number beyond the existing issue ID count.
-
Determine the highest value
iid
in the project. This will be applied to the most recent issue created from the import and can be found by querying the projects issues:GET /issues
-
Using a token with Owner permissions, create a new issue via the API, specifying an
iid
parameter with a value higher than the current issue count.POST /projects/:id/issues?title=test&iid=<all count +1>
-
Subsequent issue creations will now work normally through both the API and UI.
Cause
The issue occurs due to a problem with the internal ID counter for issues.
When a project is imported, the internal ID counter for issues is not properly initialized.
If an issue is created immediately after the import (before the counter is set), it disrupts the normal ID assignment process. Subsequent attempts to create issues fail because the system believes it's trying to create a duplicate issue (with an ID that already exists).
Additional Information
This problem specifically affects projects created through the GitLab export/import process. The issue counter (internal_ids table) is not properly set during the import process, leading to conflicts when new issues are created. The first fews issue creations after import may succeed, but subsequent creations will fail once the iid catches up with existing issue IDs.