User mapping - Placeholder User Validation Enforcement
For improved user mapping, User mapping - Placeholder User Type (!147488 - merged) introduced a service to create placeholder users based on source user information. Because placeholder users are a type of User
, there are lots of validations around the username
, name
and email
attributes.
In this issue, we need to address those validations, otherwise, a placeholder user may fail validations which could cause issues in the user mapping process. In theory, if a project is imported via Direct Transfer, user attributes should all be valid because it comes from an instance of GitLab itself. However, we'd like the user mapping feature to be usable by all importers, so we should handle validations anyway.
For now, it's fine enough to handle invalid string attributes by simply removing invalid characters. Here's a list of some known validations that need to be handled:
username
See our docs or the User
model for more details
- Must be between 2 and 255 characters in length.
- Must only include non-accented letters, digits,
_
,-
, and.
. - Must not:
- Start with
-
or.
. - Contain emoji.
- End with
.
or.<reserved file extension>
, for examplejon.png
,jon.git
orjon.atom
. However,jonpng
is valid.
- Start with
name
See the User
model for more details. Note that name
is sanitized for malicious HTML in a User
model callback
-
name
must be present and 255 characters or less -
first_name
must be 127 characters or less. Unless otherwise specifically set,first_name
is everything before the first space inname
-
last_name
must be 127 characters or less. Unless otherwise specifically set,last_name
is everything after the first space inname
email
-
email
is validated by Devise:validatable
that's included on theUser
model. We already add an email domain to the placeholder user's email, but also verify that the other validations are met. - Verify that the placeholder user's email is unique among all associated emails like the validation method
#unique_email
. Note that theunique_email
method itself just adds toerrors
, it does not return a boolean.
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.