ZendeskUsers should catch exceptions from the Zendesk library

Created on 14 February 2023, almost 2 years ago
Updated 15 February 2023, almost 2 years ago

Problem/Motivation

If the Zendesk library throws an exception, this gets caught and re-thrown by the user entity storage, as seen when reproducing the problem in this issue 🐛 Zendesk user sync not working for existing zendesk users when drupal email has capitals Closed: duplicate .

Drupal\Core\Entity\EntityStorageException: Client error: `POST https://d3v-joachim.zendesk.com/api/v2/users.json` resulted in a `422 Unprocessable Entity` response: {"error":"RecordInvalid","description":"Record validation errors","details":{"email":[{"description":"Email: capitals@he (truncated...) [details] {"error":"RecordInvalid","description":"Record validation errors","details":{"email":[{"description":"Email: capitals@here.com is already being used by another user","error":"DuplicateValue"}]}} in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object) (Line: 204)
GuzzleHttp\Promise\Promise::callHandler(1, Object, NULL) (Line: 153)
GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() (Line: 48)
GuzzleHttp\Promise\TaskQueue->run(1) (Line: 248)
GuzzleHttp\Promise\Promise->invokeWaitFn() (Line: 224)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 269)
GuzzleHttp\Promise\Promise->invokeWaitList() (Line: 226)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 62)
GuzzleHttp\Promise\Promise->wait() (Line: 129)
GuzzleHttp\Client->send(Object, Array) (Line: 92)
Zendesk\API\Http::send(Object, 'users.json', Array) (Line: 494)
Zendesk\API\HttpClient->post('users.json', Array) (Line: 32)
Zendesk\API\Resources\Core\Users->create(Array) (Line: 110)
Drupal\zendesk_users\ZendeskUsers->createUser(Object) (Line: 61)

Exceptions should be caught and logged.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom joachim

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

Comments & Activities

Production build 0.71.5 2024