Skip to content

Users widget crashes with "Cannot read properties of undefined (reading 'toString')" after any failed user save #450

Description

@MoeBeshir

Affected Version

2025.4 - LTS

Affected capability

User/Permission/Role

Steps to reproduce

  1. Register a listener on pimcore.user.preUpdate that throws Pimcore\Model\Element\ValidationException so a Studio user save is rejected. Example:
<?php

declare(strict_types=1);

namespace App\EventListener;

use Pimcore\Event\Model\UserRoleEvent;
use Pimcore\Model\Element\ValidationException;
use Pimcore\Model\User;

class BackendUserValidationListener
{
    public function onPreUpdate(UserRoleEvent $event): void
    {
        $user = $event->getUserRole();

        if (!$user instanceof User) {
            return;
        }

        $errors = [];

        $firstname = trim((string) $user->getFirstname());

        if (strlen($firstname) < 3) {
            $errors[] = 'First Name must be at least 3 characters';
        }

        $lastname = trim((string) $user->getLastname());

        if (strlen($lastname) < 3) {
            $errors[] = 'Last Name must be at least 3 characters';
        }

        $email = trim((string) $user->getEmail());

        if (empty($email)) {
            $errors[] = 'Email Address is required';
        } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $errors[] = 'Email Address is not valid';
        }

        if (!$user->getAdmin() && empty($user->getRoles())) {
            $errors[] = 'User Role is required';
        }

        if (!empty($errors)) {
            $message = "Please ensure all required fields are filled:\n"
                . implode("\n", array_map(fn($e) => '' . $e, $errors));
            throw new ValidationException($message);
        }
    }
}
# config/services.yaml
App\EventListener\BackendUserValidationListener:
    tags:
        - {
              name: kernel.event_listener,
              event: pimcore.user.preUpdate,
              method: onPreUpdate,
          }
  1. Open Studio Users and open any existing user.
  2. Clear First name (or set it to fewer than 3 characters) so the listener fails.
  3. Click Save.

Actual Behavior

The error toast is shown

Image

Then the Users widget crashes and is replaced by:

Cannot read properties of undefined (reading 'toString')

Image

The Users view stays broken until a full browser reload.

Expected Behavior

The save is rejected. An error toast is shown. The Users widget stays open and the form keeps the values that were entered.

Hoping this is already fixed in the latest version we’ll migrate to (2026.2.x).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Platform Version

    2025.4 - LTS

    Affected capability

    User/Permission/Role

    Galaxy

    None yet

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions