Notice: Undefined index: target_id in Drupal\search_overrides\Element\AddOverride::processInput()
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3207337. -->
Reported by: [mandclu](https://www.drupal.org/user/52136)
Related to !1
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Saw the error above when using version 2.0.1 on a fresh install. Here's the full test of the error:</p>
<pre>Notice: Undefined index: target_id in Drupal\search_overrides\Element\AddOverride::processInput() (line 147 of /Users/martin/Sites/search/web/modules/contrib/search_overrides/src/Element/AddOverride.php)<br>#0 /Users/martin/Sites/search/web/core/includes/bootstrap.inc(305): _drupal_error_handler_real(8, 'Undefined index...', '/Users/martin/S...', 147)<br>#1 /Users/martin/Sites/search/web/modules/contrib/search_overrides/src/Element/AddOverride.php(147): _drupal_error_handler(8, 'Undefined index...', '/Users/martin/S...', 147, Array)<br>#2 [internal function]: Drupal\search_overrides\Element\AddOverride::processInput(Array, Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request))<br>#3 /Users/martin/Sites/search/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(69): call_user_func_array(Array, Array)<br>#4 /Users/martin/Sites/search/web/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php(109): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse(Object(Symfony\Component\HttpFoundation\Request), Array, Object(Drupal\Core\Form\FormState), Array)<br>#5 [internal function]: Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))<br>#6 /Users/martin/Sites/search/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))<br>#7 /Users/martin/Sites/search/vendor/symfony/http-kernel/HttpKernel.php(219): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...')<br>#8 /Users/martin/Sites/search/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object(Drupal\Core\Form\FormAjaxException), Object(Symfony\Component\HttpFoundation\Request), 1)<br>#9 /Users/martin/Sites/search/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br>#10 /Users/martin/Sites/search/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br>#11 /Users/martin/Sites/search/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br>#12 /Users/martin/Sites/search/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br>#13 /Users/martin/Sites/search/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br>#14 /Users/martin/Sites/search/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br>#15 /Users/martin/Sites/search/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br>#16 /Users/martin/Sites/search/web/core/lib/Drupal/Core/DrupalKernel.php(706): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)<br>#17 /Users/martin/Sites/search/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))<br>#18 {main}</pre><h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>At the cited line, check that $value['target_id'] is not empty before doing the comparison.</p>
issue
GitLab AI Context
Project: project/search_overrides
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/search_overrides/-/raw/2.1.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/search_overrides
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD