User names may be a problem for certain backends

Created on 1 August 2024, 6 months ago

Problem/Motivation

This module only syncs users that have the permission to use the helpdesk. Unfortunately, that includes the user 1. And in my use case, the user name is admin which is a reserved name in GitLab and can't be synced.

The error message I receive in the logs:

Pushing users to LakeDrops GitLab failed: Gitlab\Exception\ValidationFailedException: "username" admin is a reserved name in /var/www/html/vendor/m4tthumphrey/php-gitlab-api/src/HttpClient/Plugin/ExceptionThrower.php:71 Stack trace: #0 /var/www/html/vendor/m4tthumphrey/php-gitlab-api/src/HttpClient/Plugin/ExceptionThrower.php(53): Gitlab\HttpClient\Plugin\ExceptionThrower::createException() #1 /var/www/html/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php(31): Gitlab\HttpClient\Plugin\ExceptionThrower->Gitlab\HttpClient\Plugin\{closure}() #2 /var/www/html/vendor/m4tthumphrey/php-gitlab-api/src/HttpClient/Plugin/ExceptionThrower.php(49): Http\Client\Promise\HttpFulfilledPromise->then() #3 /var/www/html/vendor/php-http/client-common/src/PluginChain.php(44): Gitlab\HttpClient\Plugin\ExceptionThrower->handleRequest() #4 /var/www/html/vendor/php-http/client-common/src/PluginChain.php(59): Http\Client\Common\PluginChain->Http\Client\Common\{closure}() #5 /var/www/html/vendor/php-http/client-common/src/PluginClient.php(87): Http\Client\Common\PluginChain->__invoke() #6 /var/www/html/vendor/php-http/client-common/src/HttpMethodsClient.php(148): Http\Client\Common\PluginClient->sendRequest() #7 /var/www/html/vendor/php-http/client-common/src/HttpMethodsClient.php(107): Http\Client\Common\HttpMethodsClient->sendRequest() #8 /var/www/html/vendor/php-http/client-common/src/HttpMethodsClient.php(75): Http\Client\Common\HttpMethodsClient->send() #9 /var/www/html/vendor/m4tthumphrey/php-gitlab-api/src/Api/AbstractApi.php(161): Http\Client\Common\HttpMethodsClient->put() #10 /var/www/html/vendor/m4tthumphrey/php-gitlab-api/src/Api/Users.php(291): Gitlab\Api\AbstractApi->put() #11 /var/www/html/web/modules/contrib/helpdesk_gitlab/src/Plugin/HelpdeskIntegration/GitLab.php(260): Gitlab\Api\Users->update() #12 /var/www/html/web/modules/contrib/helpdesk_integration/helpdesk_integration.module(66): Drupal\helpdesk_gitlab\Plugin\HelpdeskIntegration\GitLab->pushUser() #13 /var/www/html/web/core/includes/batch.inc(296): helpdesk_integration_batch_push_users() #14 /var/www/html/web/core/includes/batch.inc(138): _batch_process() #15 /var/www/html/web/core/includes/batch.inc(94): _batch_do() #16 /var/www/html/web/core/modules/system/src/Controller/BatchController.php(52): _batch_page() #17 [internal function]: Drupal\system\Controller\BatchController->batchPage() #18 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array() #19 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #20 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext() #21 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() #22 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #23 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #24 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle() #25 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #27 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle() #28 /var/www/html/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\big_pipe\StackMiddleware\ContentLength->handle() #29 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle() #30 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #31 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #32 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle() #33 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #34 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle() #35 {main}

This error would repeat as subsequent runs of user sync would try again to sync that unsinced user.

Proposed resolution

We should somehow sanitize user names.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany jurgenhaas Gottmadingen

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

Comments & Activities

Production build 0.71.5 2024