Project Access Tokens are being removed between project creation and import completion

Problem to solve

We noticed inconsistent results in relation to the systemhook “project_created”, projects being created from a template and Project Access Tokens (PrAT)

We want a PrAT set on every Project created on our instance.
The necessary trigger to our app which does this is received via the systemhook/webhook “project_created”. Our app makes a “create PrAT” POST Call, the GitLab API response is 201 in all cases. (all newly created projects)

This leads to a persistent PrAT in all cases but one. (Projects being imported, created from blank,… are ok)

Only in cases the new project originates from an instance template, the PrAT will be created (201) and is at least in the cache (redis in our case) but will not be present in the project after the import has finished. This will only happen in some cases.

We suspect a timing problem in which some mechanism deletes the PrAT after the project_created system hook is triggered
and before the import is finished.


Is this plausible to you?
Would waiting for the projects import_status to be “finished” fix this?
Projects API | GitLab | This explanation seems to fit despite being only present on “fork”
Is there a way to avoid a wait/break on our end and use a trigger webhook which only fires after import completion?

Steps to reproduce

create a system/webhook for “project_created” which triggers
→ api call to use some custom instance or group templates to create a new project, use return id to
→ make an api call to generate a Project Access Token
→ get a 201 every time, but a token in the project only sometimes

Versions

  • Self-managed
  • GitLab Enterprise Edition v17.0.4-ee

kind regards & have a good start in your weekends
Andreas Conrad