Warning: Undefined array key "id" in Drupal\jsonapi\Controller\EntityResource->patchIndividual()

Created on 26 July 2023, over 1 year ago
Updated 21 February 2024, 10 months ago

Problem/Motivation

If the patch request body doesn't contain ID, then in logs appears this warning:

Warning: Undefined array key "id" in Drupal\jsonapi\Controller\EntityResource->patchIndividual() (line 322 of /var/www/html/web/core/modules/jsonapi/src/Controller/EntityResource.php) #0 /var/www/html/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real() #1 /var/www/html/web/core/modules/jsonapi/src/Controller/EntityResource.php(322): _drupal_error_handler() #2 [internal function]: Drupal\jsonapi\Controller\EntityResource->patchIndividual() #3 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array() #4 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\@closure() #5 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext() #6 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() #7 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\@closure() #8 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #9 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle() #10 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #11 /var/www/html/web/modules/custom/upstart_commerce_blog_management/src/UpStartCommerceBlogManagementBlogMiddleware.php(85): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #12 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\upstart_commerce_blog_management\UpStartCommerceBlogManagementBlogMiddleware->handle() #13 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #14 /var/www/html/vendor/asm89/stack-cors/src/Asm89/Stack/Cors.php(60): Drupal\page_cache\StackMiddleware\PageCache->handle() #15 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Asm89\Stack\Cors->handle() #16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #17 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #18 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle() #19 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle() #20 @main.

Steps to reproduce

Send a PATCH request to any resource and skip in the body the id attribute.

Proposed resolution

Add isset() check into line 318 of class Drupal\jsonapi\Controller\EntityResource

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
JSON APIΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΊπŸ‡¦Ukraine _tarik_ Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024