Problem/Motivation
I upgraded my Drupal core instance to Drupal 9.4.5 and am using the latest Cloudinary module version 2.1.0-alpha. Since the upgrade we have been having a lot of Cloudinary errors show up in our logs. It says that Cloudinary is not configured correctly but I have all of the information added into the configuration settings in the Drupal module and my site IS connecting to Cloudinary. Error is below:
[12-Sep-2022 15:46:18 America/New_York] Uncaught PHP Exception Cloudinary\Exception\ConfigurationException: "Invalid configuration, please set up your environment" at /var/www/html/vendor/cloudinary/cloudinary_php/src/Configuration/Configuration.php line 293 request_id="v-90a50052-32d3-11ed-b793-9fbc8472a59c"
Any ideas why we are getting this error? Drupal Support at Acquia says I should ask someone at Cloudinary and Cloudinary support says to talk to the third party developers here.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 3309492-21.patch | 1.36 KB | aurora.luzzardi |
| #19 | cloudinary-3309492-18.patch | 1.47 KB | klaasvw |
| #7 | 3309492-7.patch | 1.07 KB | nginex |
| #4 | id-cloudinary-configuration-set.patch | 993 bytes | rhankins |
| #3 | image(1).jpeg | 69.66 KB | nginex |
Issue fork cloudinary-3309492
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
starrie commentedComment #3
nginex commentedHi @starrie,
Seems like the cloud name is empty based on error message from php library.
Could you please check your credenrials and ensure it's not empty and valid.
Comment #4
rhankins commentedFYI - I worked with @starrie to get a resolution for this. We had to patch one of the Cloudinary module files at: modules/contrib/cloudinary/modules/cloudinary_stream_wrapper/src/StreamWrapper/CloudinaryStreamWrapper.php
The offending line appears intending to check if the Cloudinary configuration had been set yet or not, but I suspect php 8 was causing the line to behave a little differently than intended, resulting in the configuration never getting set.
Attached is a patch file we used to resolve the issue.
Comment #5
nginex commentedHi @rhankins,
Cound you please check if the issue can be reproduced with the newest module version https://www.drupal.org/project/cloudinary/releases/2.1.0 ?
Comment #6
digital fire commentedHi @nginex,
We are running v2.1.3 of the module are reporting the same issue. We are on Drupal 9.5.7 & PHP 8.1.12.
We have the config setup with the correct credentials and when checking with the CLI, we also see the credentials.
Comment #7
nginex commentedI see some outdated code in CloudinaryStreamWrapper::__constructor()
I've provided a patch, let me know if it works for you
Comment #8
nginex commentedComment #9
digital fire commentedI applied the patch and cleared all cache. Unfortunately, we are still seeing the issue.
Was there anything else I needed to do besides those steps?
Here are the last 5 lines of the stacktrace to see if it helps..
Comment #10
nginex commentedI think I do not have enough information to reproduce the bug, could you please let me know where and when exactly do you get the error? any steps to reproduce?
Comment #11
digital fire commentedWhen viewing "/admin/content/files" it has a hard error and the page is unusable.
When trying to create/use a content type with an media field (that has cloudinary images), it has an soft error in the background that shows up in the logs.
For example; We have a basic article content type with an image field. When clicking the button that should present the media library. The ajax spinner shows up like its attempting to show but it never pops up. This is the route shown in the logs; "node/add/article?_wrapper_format=drupal_ajax&ajax_form=1"
The particular field is an entity reference field type looking at the type Media.
Comment #12
nginex commenteddid you fill in API credentials here /admin/config/media/cloudinary?
I cound only reproduce the issue when I created a cloudinary image, uninstall cloudinary module, enable the module again without providing api credentials. Once I entered api credentials and saved the form the error gone
Comment #13
digital fire commentedYes, When checking (admin/config/media/cloudinary) the credentials are in place and can also be seen when checking from the cli.
Comment #14
delacosta456 commentedhi
i was planning to use the module but unfortunately i am also having this issue withe php8.1.18 and Drupal 9.5.9
None of the patch worked for me
Any help to solve this would be welcome
Thanks
Comment #15
nginex commentedit appears that there are places where cloudinary api is used but cloudinary_sdk_init() is not triggered.
e.g. drush command
Need to refactor the way how and when cloudinary_sdk_init() is triggered.
Comment #16
kmaniAny update on the above issue? after upgrading drupal 9.5 to Drupal 10.2.2
When viewing "/admin/content/files" it has a hard error and the page is unusable.
The website encountered an unexpected error. Try again later.
InvalidArgumentException: A path was passed when a fully qualified domain was expected. in Drupal\Component\Utility\UrlHelper::externalIsLocal() (line 305 of core/lib/Drupal/Component/Utility/UrlHelper.php).
Drupal\Core\File\FileUrlGenerator->generate('cloudinary://xxxx/images/2023/09/26/test_1695696987.jpeg') (Line: 99)
Drupal\file\Plugin\Field\FieldFormatter\BaseFieldFileFormatterBase->viewElements(Object, 'en') (Line: 89)
Drupal\Core\Field\FormatterBase->view(Object, 'en') (Line: 268)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 269)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 226)
Drupal\Core\Entity\Entity\EntityViewDisplay->build(Object) (Line: 460)
Drupal\Core\Entity\EntityViewBuilder->viewField(Object, Array) (Line: 243)
Comment #17
klaasvw commentedThe real problem is indeed that
cloudinary_sdk_init()is not executed if a module like dynamic_page_cache is enabled, or drush is used.There are two reasons for that:
I'm going create an MR for 3.0.x that fixes these issues.
Comment #19
klaasvw commentedComment #20
klaasvw commentedComment #21
aurora.luzzardiI re-roll the patch after applying the patch from this MR: https://git.drupalcode.org/project/cloudinary/-/merge_requests/38 for this issue: https://www.drupal.org/project/cloudinary/issues/3428387
Comment #22
lquessenberry commentedThanks @aluzzardi. I am working on getting 3.x dev and rc5 in parity.
Comment #23
aurora.luzzardiI'm still seeing that issue, but only when running Cron.
[error] Cloudinary\Exception\ConfigurationException: Invalid configuration, please set up your environment in Cloudinary\Configuration\Configuration->validate() (line 293 of /var/www/html/vendor/cloudinary/cloudinary_php/src/Configuration/Configuration.php). [29.35 sec, 45.86 MB]Seems that when calling modules/contrib/cloudinary/modules/cloudinary_sdk/src/Service/CloudinaryAssetHelper::cloudinary() the configuration instance passing empty configuration does not work.
My suggestion to change it:
But I'm not sure what that would imply for the rest, so we need someone with more expertise on the module to help understand if we could do that change without causing any issues.
I tested locally, I started see requests to Cloudinary, but some of this are failling:
I’m not sure how these requests are being added to cron. I don’t see a hook_cron implementation in the module, so based on my review, it may be related to the thumbnail download queue for the Media type.
Please let me know if you need any additional information.
I'm on the versions:
Cloudinary: 3.0@RC5
Core: 11.2.11
With this list of patches applied:
Comment #24
aurora.luzzardi