When installing the Boina profile, I get several notices during the install process that indicate the data being serialized is not correct. This seems to originate at $jsonapi_doc_object = $serializer->normalize($response->getResponseData(), $format); missing the $context argument.

The trace of the error is

Drupal\jsonapi\Normalizer\ResourceObjectNormalizer->serializeField (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php:88)
Drupal\jsonapi\Normalizer\ResourceObjectNormalizer->normalize (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php:59)
Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\ResourceObjectNormalizerImpostor->normalize (/Users/james.flynn/git/boina/docroot/modules/contrib/jsonapi_extras/src/Normalizer/JsonApiNormalizerDecoratorBase.php:38)
Drupal\jsonapi\Normalizer\ImpostorFrom\jsonapi_extras\ResourceObjectNormalizerImpostor->normalize (/Users/james.flynn/git/boina/docroot/modules/contrib/jsonapi_extras/src/Normalizer/ResourceObjectNormalizer.php:23)
Drupal\jsonapi\Serializer\Serializer->normalize (/Users/james.flynn/git/boina/vendor/symfony/serializer/Serializer.php:143)
Drupal\jsonapi\Serializer\Serializer->normalize (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Serializer/Serializer.php:62)
Drupal\jsonapi\Normalizer\DataNormalizer->Drupal\jsonapi\Normalizer\{closure} (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Normalizer/DataNormalizer.php:26)
array_map (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Normalizer/DataNormalizer.php:27)
Drupal\jsonapi\Normalizer\DataNormalizer->normalize (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Normalizer/DataNormalizer.php:27)
Drupal\jsonapi\Serializer\Serializer->normalize (/Users/james.flynn/git/boina/vendor/symfony/serializer/Serializer.php:143)
Drupal\jsonapi\Serializer\Serializer->normalize (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Serializer/Serializer.php:62)
Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer->normalize (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php:198)
Drupal\jsonapi\Serializer\Serializer->normalize (/Users/james.flynn/git/boina/vendor/symfony/serializer/Serializer.php:143)
Drupal\jsonapi\Serializer\Serializer->normalize (/Users/james.flynn/git/boina/docroot/core/modules/jsonapi/src/Serializer/Serializer.php:62)
_gatsby_get_json_from_entity (/Users/james.flynn/git/boina/docroot/modules/contrib/gatsby/gatsby.module:99)
gatsby_entity_insert (/Users/james.flynn/git/boina/docroot/modules/contrib/gatsby/gatsby.module:58)
call_user_func_array:{/var/www/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php:403} (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php:403)
Drupal\Core\Extension\ModuleHandler->invokeAll (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php:403)
Drupal\file\FileStorage->invokeHook (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php:206)
Drupal\file\FileStorage->invokeHook (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:835)
Drupal\file\FileStorage->doPostSave (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php:527)
Drupal\file\FileStorage->doPostSave (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:720)
Drupal\file\FileStorage->save (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php:452)
Drupal\file\FileStorage->save (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:838)
Drupal\file\Entity\File->save (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Entity/EntityBase.php:394)
file_save_data (/Users/james.flynn/git/boina/docroot/core/modules/file/file.module:596)
Drupal\yaml_content\Plugin\yaml_content\process\File->process (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/Plugin/yaml_content/process/File.php:51)
Drupal\yaml_content\Plugin\YamlContentProcessManager->preprocessFieldData (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/Plugin/YamlContentProcessManager.php:84)
Drupal\yaml_content\ContentLoader\ContentLoader->populateField (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/ContentLoader/ContentLoader.php:536)
Drupal\yaml_content\ContentLoader\ContentLoader->populateEntityFields (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/ContentLoader/ContentLoader.php:457)
Drupal\yaml_content\ContentLoader\ContentLoader->buildEntity (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/ContentLoader/ContentLoader.php:367)
Drupal\yaml_content\ContentLoader\ContentLoader->populateField (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/ContentLoader/ContentLoader.php:542)
Drupal\yaml_content\ContentLoader\ContentLoader->populateEntityFields (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/ContentLoader/ContentLoader.php:457)
Drupal\yaml_content\ContentLoader\ContentLoader->buildEntity (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/ContentLoader/ContentLoader.php:367)
Drupal\yaml_content\ContentLoader\ContentLoader->loadContent (/Users/james.flynn/git/boina/docroot/modules/contrib/yaml_content/src/ContentLoader/ContentLoader.php:310)
boina_install (/Users/james.flynn/git/boina/docroot/profiles/custom/boina/boina.install:21)
call_user_func_array:{/var/www/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php:392} (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php:392)
Drupal\Core\Extension\ModuleHandler->invoke (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Extension/ModuleHandler.php:392)
Drupal\Core\Extension\ModuleInstaller->install (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/Extension/ModuleInstaller.php:303)
Drupal\Core\ProxyClass\Extension\ModuleInstaller->install (/Users/james.flynn/git/boina/docroot/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83)
install_install_profile (/Users/james.flynn/git/boina/docroot/core/includes/install.core.inc:1658)
install_run_task (/Users/james.flynn/git/boina/docroot/core/includes/install.core.inc:702)
install_run_tasks (/Users/james.flynn/git/boina/docroot/core/includes/install.core.inc:577)
install_drupal (/Users/james.flynn/git/boina/docroot/core/includes/install.core.inc:118)
drush_call_user_func_array (/Users/james.flynn/git/boina/vendor/drush/drush/includes/drush.inc:229)
drush_op (/Users/james.flynn/git/boina/vendor/drush/drush/includes/drush.inc:214)
Drush\Commands\core\SiteInstallCommands->install (/Users/james.flynn/git/boina/vendor/drush/drush/src/Commands/core/SiteInstallCommands.php:145)
call_user_func_array:{/var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php:257} (/Users/james.flynn/git/boina/vendor/consolidation/annotated-command/src/CommandProcessor.php:257)
Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback (/Users/james.flynn/git/boina/vendor/consolidation/annotated-command/src/CommandProcessor.php:257)
Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter (/Users/james.flynn/git/boina/vendor/consolidation/annotated-command/src/CommandProcessor.php:212)
Consolidation\AnnotatedCommand\CommandProcessor->process (/Users/james.flynn/git/boina/vendor/consolidation/annotated-command/src/CommandProcessor.php:178)
Consolidation\AnnotatedCommand\AnnotatedCommand->execute (/Users/james.flynn/git/boina/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:302)
Consolidation\AnnotatedCommand\AnnotatedCommand->run (/Users/james.flynn/git/boina/vendor/symfony/console/Command/Command.php:255)
Drush\Application->doRunCommand (/Users/james.flynn/git/boina/vendor/symfony/console/Application.php:987)
Drush\Application->doRun (/Users/james.flynn/git/boina/vendor/symfony/console/Application.php:255)
Drush\Application->run (/Users/james.flynn/git/boina/vendor/symfony/console/Application.php:148)
Drush\Runtime\Runtime->doRun (/Users/james.flynn/git/boina/vendor/drush/drush/src/Runtime/Runtime.php:118)
Drush\Runtime\Runtime->run (/Users/james.flynn/git/boina/vendor/drush/drush/src/Runtime/Runtime.php:49)
require (/Users/james.flynn/git/boina/vendor/drush/drush/drush.php:72)
drush_main (/Users/james.flynn/git/boina/vendor/drush/drush/includes/preflight.inc:18)
require (/Users/james.flynn/git/boina/vendor/bin/drush/bin/drush.php:141)
{main} (/Users/james.flynn/git/boina/vendor/bin/drush:10)
<code>
with relevant issues coming from line 89 of docroot/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php, method serializeField looking for the index 'account' in the $context array, which does not exist.  The $context array at the time of this method is
<code>
$context['resource_object']

which is an instance of Drupal\jsonapi\JsonApiResource\ResourceObject so the 'account' index is not available.

Per a conversation in slack, it may be possible that this module should not be relying on JSON:API PHP code, according to wimleers, "This sounds like gatsby.module is using JSON:API internals. Which it should not do. Or if it does, it may need to chase HEAD. The only API that the JSON:API module offers is … the spec-compliant JSON:API accessible via HTTP."

Comments

dorficus created an issue. See original summary.

Wim Leers’s picture

it may be possible that this module should not be relying on JSON:API functionality

I said it should not be calling JSON:API's PHP code.

dorficus’s picture

Issue summary: View changes

updated issue. my apologies.

codekarate’s picture

This is correct. It's in the roadmap to refactor this code to use the EntityToJson API that is provided in the JSON:API Extras module. This is currently in progress and we will hopefully have an update to the module soon.

  • codekarate committed bac9980 on 8.x-1.x
    Issue #3078997: _gatsby_get_json_from_entity calls to jsonapi.serializer...
codekarate’s picture

Status: Active » Fixed
codekarate’s picture

Status: Fixed » Closed (fixed)