Hi, folks look like I having problems since #3038308: Avoid translations DELETE data loss and unintended changes with PATCH and test all methods against entity route parameter translation upcasting.
I can't PATCH
my custom content entity since I updated module 2.3.0 => 2.4.0.
I have a custom content entity type, which is not translatable. The site is installed on different from the English language.
For example I send this request:
{
"data":{
"attributes":{
"due_date":"2019-03-02"
},
"id":"d38dc101-4c91-4522-a0c6-56e86a660802",
"type":"scrm-issue--scrm-issue"
}
}
And got this response:
{
"jsonapi":{
"version":"1.0",
"meta":{
"links":{
"self":{
"href":"http:\/\/jsonapi.org\/format\/1.0\/"
}
}
}
},
"errors":[
{
"title":"Method Not Allowed",
"status":"405",
"detail":"The requested translation of the resource object does not exist, instead modify one of the translations that do exist: und.",
"links":{
"via":{
"href":"http:\/\/scrm.localhost\/jsonapi\/scrm_issue\/scrm_issue\/d38dc101-4c91-4522-a0c6-56e86a660802"
},
"info":{
"href":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html#sec10.4.6"
}
},
"source":{
"file":"\/var\/www\/html\/web\/modules\/contrib\/jsonapi\/src\/ParamConverter\/EntityUuidConverter.php",
"line":78
},
"meta":{
"exception":"Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException: The requested translation of the resource object does not exist, instead modify one of the translations that do exist: und. in \/var\/www\/html\/web\/modules\/contrib\/jsonapi\/src\/ParamConverter\/EntityUuidConverter.php:78\nStack trace:\n#0 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/ParamConverter\/ParamConverterManager.php(100): Drupal\\jsonapi\\ParamConverter\\EntityUuidConverter-\u003Econvert(\u0027d38dc101-4c91-4...\u0027, Array, \u0027entity\u0027, Array)\n#1 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/Enhancer\/ParamConversionEnhancer.php(45): Drupal\\Core\\ParamConverter\\ParamConverterManager-\u003Econvert(Array)\n#2 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/Router.php(260): Drupal\\Core\\Routing\\Enhancer\\ParamConversionEnhancer-\u003Eenhance(Array, Object(Symfony\\Component\\HttpFoundation\\Request))\n#3 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/Router.php(131): Drupal\\Core\\Routing\\Router-\u003EapplyRouteEnhancers(Array, Object(Symfony\\Component\\HttpFoundation\\Request))\n#4 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/AccessAwareRouter.php(92): Drupal\\Core\\Routing\\Router-\u003EmatchRequest(Object(Symfony\\Component\\HttpFoundation\\Request))\n#5 \/var\/www\/html\/vendor\/symfony\/http-kernel\/EventListener\/RouterListener.php(115): Drupal\\Core\\Routing\\AccessAwareRouter-\u003EmatchRequest(Object(Symfony\\Component\\HttpFoundation\\Request))\n#6 [internal function]: Symfony\\Component\\HttpKernel\\EventListener\\RouterListener-\u003EonKernelRequest(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent), \u0027kernel.request\u0027, Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#7 \/var\/www\/html\/web\/core\/lib\/Drupal\/Component\/EventDispatcher\/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent), \u0027kernel.request\u0027, Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#8 \/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpKernel.php(127): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher-\u003Edispatch(\u0027kernel.request\u0027, Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))\n#9 \/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel-\u003EhandleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#10 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#11 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#12 \/var\/www\/html\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php(99): Drupal\\Core\\StackMiddleware\\KernelPreHandle-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#13 \/var\/www\/html\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php(78): Drupal\\page_cache\\StackMiddleware\\PageCache-\u003Epass(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#14 \/var\/www\/html\/web\/modules\/contrib\/jsonapi\/src\/StackMiddleware\/FormatSetter.php(45): Drupal\\page_cache\\StackMiddleware\\PageCache-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#15 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/ReverseProxyMiddleware.php(47): Drupal\\jsonapi\\StackMiddleware\\FormatSetter-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#16 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/NegotiationMiddleware.php(52): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#17 \/var\/www\/html\/vendor\/stack\/builder\/src\/Stack\/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#18 \/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/DrupalKernel.php(693): Stack\\StackedHttpKernel-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#19 \/var\/www\/html\/web\/index.php(19): Drupal\\Core\\DrupalKernel-\u003Ehandle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#20 {main}",
"trace":[
{
"file":"\/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/ParamConverter\/ParamConverterManager.php",
"line":100,
"function":"convert",
"class":"Drupal\\jsonapi\\ParamConverter\\EntityUuidConverter",
"type":"-\u003E",
"args":[
"d38dc101-4c91-4522-a0c6-56e86a660802",
{
"type":"entity:scrm_issue",
"converter":"paramconverter.jsonapi.entity_uuid"
},
"entity",
{
"_controller":"jsonapi.entity_resource:patchIndividual",
"resource_type":"scrm_issue--scrm_issue",
"_is_jsonapi":true,
"entity":"d38dc101-4c91-4522-a0c6-56e86a660802",
"_route":"jsonapi.scrm_issue--scrm_issue.individual.patch",
"_route_object":{
},
"_raw_variables":{
}
}
]
},
{
"file":"\/var\/www\/html\/web\/core\/lib\/Drupal\/Core\/Routing\/Enhancer\/ParamConversionEnhancer.php",
"line":45,
"function":"convert",
"class":"Drupal\\Core\\ParamConverter\\ParamConverterManager",
"type":"-\u003E",
"args":[
{
"_controller":"jsonapi.entity_resource:patchIndividual",
"resource_type":"scrm_issue--scrm_issue",
"_is_jsonapi":true,
"entity":"d38dc101-4c91-4522-a0c6-56e86a660802",
"_route":"jsonapi.scrm_issue--scrm_issue.individual.patch",
"_route_object":{
},
"_raw_variables":{
}
}
]
},
…
Sorry for this big response code, but I want to provide full information.
All entities created via JSON:API or Drupal UI get und
(?) langcode in JSON:API, but in fact, the default langcode for site is ru
.
And I don't understand how to patch it correctly for now. Trying to add prefix /und/ and /ru/ to the URL of JSON:API, and they throw 404 error.