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.

Issue fork cloudinary-3309492

Command icon 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

starrie created an issue. See original summary.

starrie’s picture

Version: 2.1.x-dev » 2.1.0-alpha3
Issue summary: View changes
nginex’s picture

StatusFileSize
new69.66 KB

Hi @starrie,

Seems like the cloud name is empty based on error message from php library.

php code

Could you please check your credenrials and ensure it's not empty and valid.

rhankins’s picture

StatusFileSize
new993 bytes

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

nginex’s picture

Status: Active » Needs review

Hi @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 ?

digital fire’s picture

Hi @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.

nginex’s picture

StatusFileSize
new1.07 KB

I see some outdated code in CloudinaryStreamWrapper::__constructor()

I've provided a patch, let me know if it works for you

nginex’s picture

Version: 2.1.0-alpha3 » 2.1.x-dev
digital fire’s picture

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

Cloudinary\Asset\BaseAsset::fromParams('2023-04/test image12345678.jpg', Array) (Line: 73)
Cloudinary\Asset\BaseMediaAsset::fromParams('2023-04/test image12345678.jpg') (Line: 368)
Drupal\cloudinary_stream_wrapper\StreamWrapper\CloudinaryStreamWrapper->getExternalUrl() (Line: 189)
Drupal\Core\File\FileUrlGenerator->generate('cloudinary://2023-04/test image12345678.jpg') (Line: 103)
Drupal\file\Plugin\Field\FieldFormatter\BaseFieldFileFormatterBase->viewElements(Object, 'en') (Line: 89)

nginex’s picture

I 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?

digital fire’s picture

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

nginex’s picture

did 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

digital fire’s picture

Yes, When checking (admin/config/media/cloudinary) the credentials are in place and can also be seen when checking from the cli.

delacosta456’s picture

hi
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

nginex’s picture

Status: Needs review » Needs work

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

kmani’s picture

Any 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)

klaasvw’s picture

Version: 2.1.x-dev » 3.0.x-dev
Assigned: Unassigned » klaasvw
Status: Needs work » Needs review

The 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:

  • dynamic_page_cache has priority 27 when subscribing to KernelEvents::REQUEST, which is higher than cloudindary
  • drush doesn't use the KernelEvents::REQUEST event

I'm going create an MR for 3.0.x that fixes these issues.

klaasvw’s picture

StatusFileSize
new1.47 KB
klaasvw’s picture

aurora.luzzardi’s picture

StatusFileSize
new1.36 KB
lquessenberry’s picture

Thanks @aluzzardi. I am working on getting 3.x dev and rc5 in parity.

aurora.luzzardi’s picture

I'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:

public static function cloudinary() {
    $config = cloudinary_sdk_config_load();
    if (!$config) {
      throw new ConfigurationException('Cloudinary configuration is not set.');
    }
    $config_instance = Configuration::instance();
    if (!$config_instance->cloud->cloudName) {
      throw new ConfigurationException();
    }
    return new Cloudinary($config_instance);
  }

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:

[2026-04-28T15:31:34.795337-04:00] cloudinary.CRITICAL: Request to Cloudinary server returned an error {"statusCode":404,"message":"Resource not found - mage-events-training-banner.png"} []
[2026-04-28T15:31:34.795695-04:00] cloudinary.CRITICAL: Async request failed {"code":0,"message":"Resource not found - image-events-training-banner.png"} []
[2026-04-28T15:31:38.687694-04:00] cloudinary.CRITICAL: Request to Cloudinary server returned an error {"statusCode":404,"message":"Resource not found - cid-sample.jpg"} []
[2026-04-28T15:31:38.687914-04:00] cloudinary.CRITICAL: Async request failed {"code":0,"message":"Resource not found - cid-sample.jpg"} []

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:

"3428387: Automated Drupal 11 compatibility fixes for cloudinary": "https://www.drupal.org/files/issues/2026-03-17/3428387-38.diff.patch",
            "3354894: Cloudinary Stream Wrapper caches items in the database (Database Storage) but never actually checks if an item is inside the storage": "https://www.drupal.org/files/issues/2024-06-20/cloudinary-3354894-7.patch",
            "3455065: Missing file entity filesize property": "https://www.drupal.org/files/issues/2024-10-09/cloudinary-3455065-5.patch",
            "3431899: TypeError: Drupal\\cloudinary_media_library_widget\\Form\\CloudinaryUploadForm::__construct(): Argument #2 ($library_ui_builder) must be of type Drupal\\media_library\\MediaLibraryUiBuilderInterface, Drupal\\media_library\\MediaLibraryUiBuilder @cloudinary 3.0.0": "https://www.drupal.org/files/issues/2024-04-22/cloudinary-3431899-5.patch",
            "3479908: Database storage only works with ASCII public_id": "https://www.drupal.org/files/issues/2024-10-10/cloudinary-3479908-2.patch",
            "3394440: Fix dynamic property $context issue": "https://www.drupal.org/files/issues/2025-04-21/3394440-fix-dynamic-property.patch",
            "3309492: Configuration errors with Cloudinary after upgrading to Drupal 9.4.5": "https://www.drupal.org/files/issues/2026-03-17/3309492-21.patch",
            "3458458: PDF File Missing Extension in Generated URL": "https://www.drupal.org/files/issues/2024-07-20/cloudinary-506472d-fix-the-stream-wrapper-undefined-URI-and-set-the-correct-asset-type-plus-the-extension.patch",
            "3581764: After D11 update and module Update none of the images styles applies": "https://www.drupal.org/files/issues/2026-04-16/3581764-4.patch",
aurora.luzzardi’s picture

Status: Needs review » Needs work