Hi,
I have a taxonomy vocab that I am trying to request via jsonapi and keep getting the following error..
{"errors":[{"title":"Internal Server Error","status":500,"detail":"setRelatableResourceTypes() must be called before getting relatable resource types.","links":{"info":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html#sec10.5.1"},"code":0}]}
Trace:
<ROOT>/modules/contrib/jsonapi/src/ResourceType/ResourceType.php:222 [kint()]
<ROOT>/modules/contrib/jsonapi/src/ResourceType/ResourceType.php:241 [Drupal\jsonapi\ResourceType\ResourceType->getRelatableResourceTypes()]
<ROOT>/modules/contrib/jsonapi/src/Normalizer/Value/RelationshipNormalizerValue.php:97 [Drupal\jsonapi\ResourceType\ResourceType->getRelatableResourceTypesByField()]
<ROOT>/modules/contrib/jsonapi/src/Normalizer/Value/RelationshipNormalizerValue.php:68 [Drupal\jsonapi\Normalizer\Value\RelationshipNormalizerValue->getLinks()]
<ROOT>/modules/contrib/jsonapi/src/Normalizer/Value/EntityNormalizerValue.php:109 [Drupal\jsonapi\Normalizer\Value\RelationshipNormalizerValue->rasterizeValue()]
<ROOT>/modules/contrib/jsonapi/src/Normalizer/Value/JsonApiDocumentTopLevelNormalizerValue.php:127 [Drupal\jsonapi\Normalizer\Value\EntityNormalizerValue->rasterizeValue()]
<ROOT>/modules/contrib/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php:203 [Drupal\jsonapi\Normalizer\Value\JsonApiDocumentTopLevelNormalizerValue->rasterizeValue()]
.../vendor/symfony/serializer/Serializer.php:128 [Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer->normalize()]
<ROOT>/modules/contrib/jsonapi/src/Serializer/Serializer.php:46 [Symfony\Component\Serializer\Serializer->normalize()]
.../vendor/symfony/serializer/Serializer.php:101 [Drupal\jsonapi\Serializer\Serializer->normalize()]
<ROOT>/modules/contrib/jsonapi/src/EventSubscriber/ResourceResponseSubscriber.php:218 [Symfony\Component\Serializer\Serializer->serialize()]
<ROOT>/core/lib/Drupal/Core/Render/Renderer.php:574 [Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber->Drupal\jsonapi\EventSubscriber\{closure}()]
<ROOT>/modules/contrib/jsonapi/src/EventSubscriber/ResourceResponseSubscriber.php:221 [Drupal\Core\Render\Renderer->executeInRenderContext()]
<ROOT>/modules/contrib/jsonapi/src/EventSubscriber/ResourceResponseSubscriber.php:166 [Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber->renderResponseBody()]
<ROOT>/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111 [Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber->onResponse()]
.../vendor/symfony/http-kernel/HttpKernel.php:175 [Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()]
.../vendor/symfony/http-kernel/HttpKernel.php:157 [Symfony\Component\HttpKernel\HttpKernel->filterResponse()]
.../vendor/symfony/http-kernel/HttpKernel.php:57 [Symfony\Component\HttpKernel\HttpKernel->handleRaw()]
<ROOT>/core/lib/Drupal/Core/StackMiddleware/Session.php:57 [Symfony\Component\HttpKernel\HttpKernel->handle()]
<ROOT>/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:47 [Drupal\Core\StackMiddleware\Session->handle()]
<ROOT>/core/modules/page_cache/src/StackMiddleware/PageCache.php:207 [Drupal\Core\StackMiddleware\KernelPreHandle->handle()]
<ROOT>/core/modules/page_cache/src/StackMiddleware/PageCache.php:121 [Drupal\page_cache\StackMiddleware\PageCache->fetch()]
<ROOT>/core/modules/page_cache/src/StackMiddleware/PageCache.php:75 [Drupal\page_cache\StackMiddleware\PageCache->lookup()]
<ROOT>/modules/contrib/jsonapi/src/StackMiddleware/FormatSetter.php:40 [Drupal\page_cache\StackMiddleware\PageCache->handle()]
<ROOT>/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:47 [Drupal\jsonapi\StackMiddleware\FormatSetter->handle()]
<ROOT>/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:50 [Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()]
.../vendor/stack/builder/src/Stack/StackedHttpKernel.php:23 [Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()]
<ROOT>/core/lib/Drupal/Core/DrupalKernel.php:656 [Stack\StackedHttpKernel->handle()]
<ROOT>/index.php:19 [Drupal\Core\DrupalKernel->handle()]
Any ideas?
Comments
Comment #2
gabesullice@dakku,
I know exactly where this is coming from. I didn't think it was possible to run into that error though.
I'll look into this on Monday.
Would you mind including the URL of the request?
Comment #3
dakku commentedHi @gabesullice, thanks for the reply, how are things in OCTO?
My setup is:
- vocab called 'testvocab'
- testvocab contains a term called 'testterm'
- I have jsonapi endpoint at '/jsonapi/taxonomy_term/testvocab'
Any hints on why I might be hitting that problem?
Comment #4
gabesulliceGood, thanks!
Not yet, I'm actually just starting to debug it now.
Comment #5
gabesulliceI just tried to replicate this locally and was not able to.
You must be running a dev version of the module to be getting that error, are you on the latest version? If not, would you try to update to the latest? Is there any chance you're just hitting this in tests?
Comment #6
dakku commentedhey @gabesullice. I was on the stable version and was seeing this issue, now I have updated to the dev release and still the same problem.
here is what I have tried:
I also tried the dev releases of both modules.. The good news however is that you were not able to re-produce this locally, let me tinker a bit more to see if its an issue on my side.
Comment #7
gabesulliceFWIW, jsonapi 1.1 is far behind :\ stable is 1.7.
I think you may actually have a different version of the module in your modules directory than is listed by composer.json. I'm 100% certain that the
setRelatableResourceTypes()method is not on the stable branch.Comment #8
swentel commentedI get that error too when using jsonapi 8.1.10 with jsonapi_extras dev
8.1.10 jsonapi with jsonapi_extras rc1 triggered following error first when doing drush cr.
In combination with jsonapi_extras dev, drush cr is fine, but doing a GET collection call I get:
LogicException: setRelatableResourceTypes() must be called before getting relatable resource types. in Drupal\jsonapi\ResourceType\ResourceType->getRelatableResourceTypes() (line 223 of /home/drupal/modules/jsonapi/src/ResourceType/ResourceType.php).Comment #9
swentel commentedPossibly related with https://www.drupal.org/project/jsonapi_extras/issues/2942340 and/or https://www.drupal.org/project/jsonapi_extras/issues/2942340 maybe ?
Comment #10
gabesullice@swentel, that makes perfect sense. I've confirmed that the issue is in JSON API Extras. JSON API Extras is instantiating its own ResourceTypes and isn't updated to use the new internal/related work we've been working on here.
Those particular issues probably aren't the cause, but I'll look into and file an issue for JSON API Extras.
I'll relate it to this issue so you can find it in the sidebar once it's created.Edit: Issue and patch available here: #2946790: ConfigurableResourceTypeRepository does not call setRelatableResourceTypes()
Comment #11
dakku commented@gabesullice thank you for the patch, I will try it out with jsonapi extras.