GuzzleHttp\Exception\ClientException not caught

Created on 8 July 2024, 3 months ago
Updated 9 July 2024, 3 months ago

Problem/Motivation

I created a new media type using the Unsplash external plugin. I then went to create a new media entity.

I added https://unsplash.com/photos/venice-canal-t2yh3mlISdQ as the external URL then saved the form.

I got this exception:

GuzzleHttp\Exception\ClientException: Client error: `GET https://api.unsplash.com/photos/https://unsplash.com/photos/venice-canal...` resulted in a `404 Not Found` response: {"errors":["Not found"]} in GuzzleHttp\Exception\RequestException::create() (line 113 of /var/www/html/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php).

GuzzleHttp\Middleware::GuzzleHttp\{closure}() (Line: 209)
GuzzleHttp\Promise\Promise::callHandler() (Line: 158)
GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() (Line: 52)
GuzzleHttp\Promise\TaskQueue->run() (Line: 251)
GuzzleHttp\Promise\Promise->invokeWaitFn() (Line: 227)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 272)
GuzzleHttp\Promise\Promise->invokeWaitList() (Line: 229)
GuzzleHttp\Promise\Promise->waitIfPending() (Line: 69)
GuzzleHttp\Promise\Promise->wait() (Line: 189)
GuzzleHttp\Client->request() (Line: 44)
GuzzleHttp\Client->get() (Line: 103)
Drupal\media_external\Plugin\media\ExternalMediaProvider\Unsplash->load() (Line: 73)
Drupal\media_external\ExternalMediaCacheWrapper->load() (Line: 201)
Drupal\media_external\Plugin\media\Source\ExternalMedia->getMetadata() (Line: 105)
Drupal\media\Entity\Media->getName() (Line: 444)
Drupal\media\Entity\Media->prepareSave() (Line: 27)
Drupal\media\MediaStorage->save() (Line: 354)
Drupal\Core\Entity\EntityBase->save() (Line: 293)
Drupal\Core\Entity\EntityForm->save() (Line: 61)
Drupal\media\MediaForm->save()
call_user_func_array() (Line: 129)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (Line: 67)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.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

  • Issue created by @joachim
  • 🇳🇱Netherlands seanB Netherlands

    Instead of the URL I think we only need an ID. That being said, we should probably not throw and error. We might be able to do the following:

    • Harden the code to show better error messages when something goes wrong
    • Automatically extract an ID from URLs before we call the API

    Would you be able to create a PR for this?

Production build 0.71.5 2024