Problem/Motivation

We're seeing quite a few of these errors on Acquia Cloud running Drupal 9.3.9 and acquia_connector 3.0.4:

TypeError: Argument 3 passed to Drupal\acquia_connector\ConnectorException::__construct() must be of the type array, null given, called in /mnt/www/html/app/docroot/modules/contrib/acquia_connector/src/Client.php on line 343 in Drupal\acquia_connector\ConnectorException->__construct() (line 32 of /mnt/www/html/app/docroot/modules/contrib/acquia_connector/src/ConnectorException.php).

Steps to reproduce

Haven't been able to nail this down yet. It happens during cron runs which we use Drush 11.0.5 for.

Proposed resolution

TBD but could checking to see if $data is an array before throwing the exception suffice?

Remaining tasks

Identify cause and propose resolution.

User interface changes

None.

API changes

None.

Data model changes

None.

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

richardbporter created an issue. See original summary.

andrii-severynenko’s picture

I've got the same issue. Not only during Cron run but also in case of manual Acquia Subscription Refresh action on the Drupal Status page. It seems sometimes Acquia endpoint responds with NULL body but ConnectorException expects Array as a 3rd argument of the __construct() method. Definitely it needs to be verified that $data variable is an Array before pass it as a 3rd argument.

japerry’s picture

Status: Active » Postponed (maintainer needs more info)

I -think- this is fixed with some of the changes we made to the drush commands. I'd give the new 4.x beta a try and see if that fixes things.

moshe weitzman’s picture

Happening on mass.gov as well (we just upgraded to php8.0). The release notes for that release say "This is an incremental update to the beta program for Connector 4.x. This version should be used by Acquia Search 3.1.x beta testers, as well as Acquia Perz beta customers.". We are not part of a "beta program", nor do we use either of those products. Is it safe to use the beta?

rodetrev made their first commit to this issue’s fork.

dmitry.korhov’s picture

Status: Postponed (maintainer needs more info) » Needs review

@japerry,
Can we fix it w\o beta or dev release? It starts annoying.
update: it was not fixed in 4.0-beta:
Still can be NULL: https://git.drupalcode.org/project/acquia_connector/-/blob/bd55b9bd4156b...
&
Still expects array: https://git.drupalcode.org/project/acquia_connector/-/blob/bd55b9bd4156b...

https://www.php.net/manual/en/function.json-decode.php
Returns the value encoded in json in appropriate PHP type. Values true, false and null are returned as true, false and null respectively. null is returned if the json cannot be decoded or if the encoded data is deeper than the nesting limit.

rodetrev’s picture

"acquia_connector/src/Client/AcquiaConnectorClient.php" line 267 and line 280 return NULL ConnectorException in line 270 and 283 is expecting an array as a 3rd parameter. I have changed the code to use an empty array if Json::decode is returning NULL or FALSE.

$data = Json::decode($response->getBody()->read($stream_size)) ?: [];

This fixes the issue.

timwood’s picture

Version: 3.0.4 » 4.x-dev
Priority: Normal » Major
Status: Needs review » Needs work

This issue caused or contributed to an outage with one of our Acquia hosted sites. We have requested Acquia to investigate. We are running the -dev version as of commit `bd55b9b` from 8/4/2022 (which I believe matches the current beta release). @japerry can you look into this a bit more? Here was the error:

 [warning] Trying to access array offset on value of type null AcquiaConnectorClient.php:310

Fatal error: Uncaught TypeError: Drupal\acquia_connector\ConnectorException::__construct(): Argument #3 ($custom) must be of type array, null given, called in /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_connector/src/Client/AcquiaConnectorClient.php on line 310 and defined in /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_connector/src/ConnectorException.php:32
Stack trace:
#0 /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_connector/src/Client/AcquiaConnectorClient.php(310): Drupal\acquia_connector\ConnectorException->__construct()
#1 /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_connector/src/Client/AcquiaConnectorClient.php(411): Drupal\acquia_connector\Client\AcquiaConnectorClient->request()
#2 /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_connector/src/Client/AcquiaConnectorClient.php(147): Drupal\acquia_connector\Client\AcquiaConnectorClient->nspiCall()
#3 /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_connector/src/Subscription.php(181): Drupal\acquia_connector\Client\AcquiaConnectorClient->getSubscription()
#4 /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_search/src/PreferredCoreService.php(144): Drupal\acquia_connector\Subscription->getSubscription()
#5 /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_search/acquia_search.module(57): Drupal\acquia_search\PreferredCoreService->getPreferredCore()
#6 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(434): acquia_search_search_api_server_load()
#7 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Entity\EntityStorageBase->Drupal\Core\Entity\{closure}()
#8 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(435): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#9 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(353): Drupal\Core\Entity\EntityStorageBase->postLoad()
#10 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(296): Drupal\Core\Entity\EntityStorageBase->loadMultiple()
#11 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityBase.php(488): Drupal\Core\Entity\EntityStorageBase->load()
#12 /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_search/acquia_search.module(121): Drupal\Core\Entity\EntityBase::load()
#13 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(434): acquia_search_search_api_index_load()
#14 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Entity\EntityStorageBase->Drupal\Core\Entity\{closure}()
#15 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(435): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#16 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(353): Drupal\Core\Entity\EntityStorageBase->postLoad()
#17 /mnt/www/html/SITENAME/docroot/modules/contrib/search_api_solr/src/Plugin/DataType/Deriver/SolrDocumentDeriver.php(74): Drupal\Core\Entity\EntityStorageBase->loadMultiple()
#18 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\search_api_solr\Plugin\DataType\Deriver\SolrDocumentDeriver->getDerivativeDefinitions()
#19 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives()
#20 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(285): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#21 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(175): Drupal\Core\Plugin\DefaultPluginManager->findDefinitions()
#22 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(22): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
#23 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/TypedData/DataDefinition.php(195): Drupal\Core\Plugin\DefaultPluginManager->getDefinition()
#24 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Field/BaseFieldDefinition.php(606): Drupal\Core\TypedData\DataDefinition->getClass()
#25 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Field/BaseFieldDefinition.php(463): Drupal\Core\Field\BaseFieldDefinition->getMainPropertyName()
#26 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/RevisionLogEntityTrait.php(54): Drupal\Core\Field\BaseFieldDefinition->setDefaultValue()
#27 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EditorialContentEntityBase.php(23): Drupal\Core\Entity\EditorialContentEntityBase::revisionLogBaseFieldDefinitions()
#28 /mnt/www/html/SITENAME/docroot/core/modules/block_content/src/Entity/BlockContent.php(180): Drupal\Core\Entity\EditorialContentEntityBase::baseFieldDefinitions()
#29 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityFieldManager.php(228): Drupal\block_content\Entity\BlockContent::baseFieldDefinitions()
#30 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Entity/EntityFieldManager.php(193): Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions()
#31 /mnt/www/html/SITENAME/docroot/modules/contrib/dynamic_entity_reference/dynamic_entity_reference.views.inc(318): Drupal\Core\Entity\EntityFieldManager->getBaseFieldDefinitions()
#32 /mnt/www/html/SITENAME/docroot/modules/contrib/dynamic_entity_reference/dynamic_entity_reference.views.inc(134): dynamic_entity_reference_get_all_base_fields()
#33 /mnt/www/html/SITENAME/docroot/core/modules/views/src/ViewsData.php(236): dynamic_entity_reference_views_data()
#34 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\views\ViewsData->Drupal\views\{closure}()
#35 /mnt/www/html/SITENAME/docroot/core/modules/views/src/ViewsData.php(244): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#36 /mnt/www/html/SITENAME/docroot/core/modules/views/src/ViewsData.php(154): Drupal\views\ViewsData->getData()
#37 /mnt/www/html/SITENAME/docroot/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php(91): Drupal\views\ViewsData->get()
#38 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\views\Plugin\Derivative\ViewsEntityRow->getDerivativeDefinitions()
#39 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives()
#40 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(285): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#41 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(175): Drupal\Core\Plugin\DefaultPluginManager->findDefinitions()
#42 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(22): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions()
#43 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php(16): Drupal\Core\Plugin\DefaultPluginManager->getDefinition()
#44 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Component/Plugin/PluginManagerBase.php(83): Drupal\Core\Plugin\Factory\ContainerFactory->createInstance()
#45 /mnt/www/html/SITENAME/docroot/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(817): Drupal\Component\Plugin\PluginManagerBase->createInstance()
#46 /mnt/www/html/SITENAME/docroot/core/modules/views/src/Plugin/views/style/StylePluginBase.php(122): Drupal\views\Plugin\views\display\DisplayPluginBase->getPlugin()
#47 /mnt/www/html/SITENAME/docroot/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(820): Drupal\views\Plugin\views\style\StylePluginBase->init()
#48 /mnt/www/html/SITENAME/docroot/core/modules/rest/src/Plugin/views/display/RestExport.php(346): Drupal\views\Plugin\views\display\DisplayPluginBase->getPlugin()
#49 /mnt/www/html/SITENAME/docroot/core/modules/views/src/EventSubscriber/RouteSubscriber.php(120): Drupal\rest\Plugin\views\display\RestExport->collectRoutes()
#50 [internal function]: Drupal\views\EventSubscriber\RouteSubscriber->routes()
#51 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/Routing/RouteBuilder.php(146): call_user_func()
#52 /mnt/www/html/SITENAME/docroot/core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild()
#53 /mnt/www/html/SITENAME/docroot/core/includes/common.inc(587): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild()
#54 /mnt/www/html/SITENAME/docroot/core/includes/utility.inc(41): drupal_flush_all_caches()
#55 /mnt/www/html/SITENAME/vendor/drush/drush/src/Commands/core/CacheCommands.php(234): drupal_rebuild()
#56 [internal function]: Drush\Commands\core\CacheCommands->rebuild()
#57 /mnt/www/html/SITENAME/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array()
#58 /mnt/www/html/SITENAME/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#59 /mnt/www/html/SITENAME/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#60 /mnt/www/html/SITENAME/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process()
#61 /mnt/www/html/SITENAME/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#62 /mnt/www/html/SITENAME/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run()
#63 /mnt/www/html/SITENAME/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#64 /mnt/www/html/SITENAME/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#65 /mnt/www/html/SITENAME/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run()
#66 /mnt/www/html/SITENAME/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun()
#67 /mnt/www/html/SITENAME/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run()
#68 /mnt/www/html/SITENAME/vendor/drush/drush/drush(4): require('...')
#69 /mnt/www/html/SITENAME/vendor/bin/drush(107): include('...')
#70 {main}
  thrown in /mnt/www/html/SITENAME/docroot/modules/contrib/acquia_connector/src/ConnectorException.php on line 32
nkoporec’s picture

Status: Needs work » Needs review
StatusFileSize
new1.2 KB
new1.33 KB

I have created a patches for both 3.x and 4.x versions, that should resolve this issue. Since its a small fix, I didn't want to open up a separate issue for 3.x.

  • japerry committed f9547bb on 3.x
    Issue #3273706 by nkoporec: Update client request error when no data is...
japerry’s picture

Version: 4.x-dev » 3.x-dev
Status: Needs review » Fixed

Fixed in the 3.x branch. The 4.x branch will be getting a new beta shortly that replaces the entire legacy API with an oauth based flow, so this patch won't be valid there.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.