Hi,
So is setup a rest API with core's REST modules and users with adresses field.
using the endpoint POST /entity/user?_format=json
one of my client sent a badly formed json such as (lacking the array around the adress field):
{
"name": [
{
"value": "XXX@gmail.com"
}
],
"mail":
{
"value": "XXX@gmail.com"
}
,
"pass": [
{
"value": "XXXXXXXX",
"pre_hashed": false
}
],
"status": [
{
"value": true
}
],
"field_adresse":
{
"langcode": "",
"country_code": "FR",
"administrative_area": null,
"locality": "Paris",
"dependent_locality": null,
"postal_code": "75012",
"sorting_code": null,
"address_line1": "7 rue des testeurs",
"address_line2": null,
"organization": null,
"given_name": "Unintest",
"additional_name": null,
"family_name": "Testeur43"
}
}
He got a status 500500 Service unavailable (with message)
The website encountered an unexpected error. Please try again later.
Error: Call to a
member function getClass() on null in
Drupal\serialization\Normalizer\FieldItemNormalizer->constructValue() (line
242 of
core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php).
Drupal\serialization\Normalizer\FieldItemNormalizer->constructValue('', Array) (Line: 38) Drupal\serialization\Normalizer\FieldItemNormalizer->denormalize('', 'Drupal\address\Plugin\Field\FieldType\AddressItem', 'json', Array) (Line: 182) Symfony\Component\Serializer\Serializer->denormalize('', 'Drupal\address\Plugin\Field\FieldType\AddressItem', 'json', Array) (Line: 52) Drupal\serialization\Normalizer\FieldNormalizer->denormalize(Array, 'Drupal\address\Plugin\Field\FieldType\AddressFieldItemList', 'json', Array) (Line: 182) Symfony\Component\Serializer\Serializer->denormalize(Array, 'Drupal\address\Plugin\Field\FieldType\AddressFieldItemList', 'json', Array) (Line: 151) Drupal\serialization\Normalizer\EntityNormalizer->denormalizeFieldData(Array, Object, 'json', Array) (Line: 72) Drupal\serialization\Normalizer\EntityNormalizer->denormalize(Array, 'Drupal\user\Entity\User', 'json', Array) (Line: 182) Symfony\Component\Serializer\Serializer->denormalize(Array, 'Drupal\user\Entity\User', 'json', Array) (Line: 196) Drupal\rest\RequestHandler->deserialize(Object, Object, Object) (Line: 79) Drupal\rest\RequestHandler->handle(Object, Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Expected:
a status 422Unprocessable Entity with an appropriate error message
It might be an issue with core's serialization but since it works with other fields types i post it here,
sorry if I am wrong
Closed: outdated
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.