Creation of user names

Created on 7 April 2025, 21 days ago

Problem/Motivation

When using the Group Members Import module, it's possible to provide a user.name value (e.g. via CSV field or mapping). However, this value is ignored, and the module always tries to derive the username from the user.mail field instead.

This causes two main problems:

  1. Explicit user.name values are ignored, even if provided intentionally. As a result, usernames are not set as expected.
  2. Email-based fallback leads to duplicates, especially when common email addresses like info@... or kontakt@... are used across multiple users. Eventually, this results in EntityStorageException errors such as:
    Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'info_5-de' for key 'user__name'
        

While deriving the username from the email address may be desirable as a fallback feature, it must be implemented reliably – especially in batch operations.

Steps to reproduce

  1. Prepare a user import via Group Members Import.
  2. Provide a CSV file containing both user.name and user.mail.
  3. Use the same generic email (e.g. info@domain.tld) for several entries.
  4. Run the import.
  5. Observe:
    • user.name is ignored.
    • Username is generated from user.mail.
    • Duplicates occur, causing import to fail.

Proposed resolution

  • Respect user.name when explicitly set – this should take precedence.
  • Only use user.mail as a fallback when user.name is empty or missing.
  • Add proper collision detection and handling for email-based username fallback (e.g. auto-suffixing like info_1, info_2, etc.).
  • Consider logging or user feedback if fallback is used or a collision is avoided.

Priority

Suggested: Normal or Major if it's blocking batch imports.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

🇦🇹Austria ChrisZZ Vienna

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024