Problem/Motivation
While there is some exception in RemoteManager::doRequest method with empty $options parameter this method returns NULL.
Client exception when requesting the URL: https://domain.com/jsonapi/taxonomy_term/tag/9f2d03f5-f9fc-406b-b84b-8bf377431cfb/parent with method GET: Client error: `GET https://domain.com/jsonapi/taxonomy_term/tag/9f2d03f5-f9fc-406b-b84b-8bf377431cfb/parent` resulted in a `404 Not Found` response
Error: Call to a member function getBody() on null in Drupal\entity_share_client\Plugin\EntityShareClient\Processor\EntityReference->importUrl() (line 241 of modules/contrib/entity_share/modules/entity_share_client/src/Plugin/EntityShareClient/Processor/EntityReference.php
Steps to reproduce
We are occasionally, getting this error while some entity are removed from server but jsonApi served from cache.
Proposed resolution
Add a check for Null value return from jsonApiRequest method in
modules/entity_share_client/src/Plugin/EntityShareClient/Processor/EntityReference.php line number 244.
$referenced_entities_response = $this->remoteManager->jsonApiRequest($runtime_import_context->getRemote(), 'GET', $url);
Remaining tasks
Add patch
User interface changes
NA
API changes
NA
Data model changes
NA
Comments
Comment #2
bunty badgujar commentedAdd null check on response.
Comment #3
bunty badgujar commentedComment #4
grimreaperHello,
Thanks for reporting this.
I think this should be done as
Comment #5
grimreaperStrange, because when I go in a fake URL like:
- https://site1-web-entity-share.docker.localhost/jsonapi/taxonomy_term/es...
- https://site1-web-entity-share.docker.localhost/jsonapi/taxonomy_term/es...
Where there is no taxonomy term with this UUID, for both URLs I have a JSON API response (in 404).
And also even with cache, when udpating/deleting your content entities, JSON:API cache should be invalidated properly so this should not happen.
Can you please provide detailed steps to reproduce the bug starting from a fresh standard install?
Comment #6
arpitr commentedI think condition handling would be better since importURL() method is expecting response to be a valid guzzle response object whereas in case of exception NULL is returned, this creates situation to cause Error.
There are scenarios created by issues in other modules https://www.drupal.org/project/memcache/issues/2996615 which could cause the json API to not update in certain situations.
Though this is less likely to happen but better type check and make it less error prone.
Comment #7
grimreaperHello @arpitr,
Thanks for pointing this.
I will update the patch using MR.
Comment #9
grimreaperI have updated the patch to change other spaces where this logic happened.
I will merge if tests are green.
Comment #11
grimreaperMerged!
Thanks everyone!