Missing organization for placeholder user

I ran a validation query against production data: checking if we have user records that do not belong to an organization.

I found 47554 user records that don't have an organization. They are all user_type: 15, placeholder

The first record was created 2025-02-05 17:11:26 (UTC).

This is related to import feature. Somehow, we do not assign an organization to an User

I found Remove User after commit hook for assigning use... (!175288 - merged) which caused this. The timestamp of the deploy and the first record that has this issue correlate.

Solution

Gitlab::Import::PlaceholderUserCreator is using User model directly when creating a new User.

We can replace that by Users::AuthorizedBuildService. This will take care of organization association.

Fixing data

When the fix has been merged, we can verify that all placeholder users are now linked to an organization

After that, one follow up MR is needed that will fix the existing data

Edited by Rutger Wessels