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.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3273706-10-4.x.patch | 1.33 KB | nkoporec |
| #10 | 3273706-10-3.x.patch | 1.2 KB | nkoporec |
Issue fork acquia_connector-3273706
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
andrii-severynenko commentedI'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.
Comment #3
japerryI -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.
Comment #4
moshe weitzman commentedHappening 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?
Comment #7
dmitry.korhov@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.
Comment #8
rodetrev commented"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.
Comment #9
timwoodThis 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:
Comment #10
nkoporecI 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.
Comment #12
japerryFixed 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.