PluginNotFoundException thrown by VDB provider call, related to search_api_node_grants field
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3528233. --> Reported by: [lpeabody](https://www.drupal.org/user/1137356) Related to !984 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>This issue is encountered with Pinecone VDB provider but I think the issue belongs here. With a RAG agent configured to search an index backed by Pinecone, I get the following error:</p> <pre> Warning: Undefined array key 1 in Drupal\ai\Base\AiVdbProviderClientBase-&gt;isMultiple() (line 383 of /var/www/html/web/modules/contrib/ai/src/Base/AiVdbProviderClientBase.php) #0 /var/www/html/web/core/includes/bootstrap.inc(108): _drupal_error_handler_real() #1 /var/www/html/web/modules/contrib/ai/src/Base/AiVdbProviderClientBase.php(383): _drupal_error_handler() #2 /var/www/html/web/modules/contrib/ai_vdb_provider_pinecone/src/Plugin/VdbProvider/PineconeProvider.php(497): Drupal\ai\Base\AiVdbProviderClientBase-&gt;isMultiple() #3 /var/www/html/web/modules/contrib/ai_vdb_provider_pinecone/src/Plugin/VdbProvider/PineconeProvider.php(484): Drupal\ai_vdb_provider_pinecone\Plugin\VdbProvider\PineconeProvider-&gt;processConditionGroup() #4 /var/www/html/web/modules/contrib/ai_vdb_provider_pinecone/src/Plugin/VdbProvider/PineconeProvider.php(464): Drupal\ai_vdb_provider_pinecone\Plugin\VdbProvider\PineconeProvider-&gt;processConditionGroup() #5 /var/www/html/web/modules/contrib/ai/modules/ai_search/src/Plugin/search_api/backend/SearchApiAiSearchBackend.php(413): Drupal\ai_vdb_provider_pinecone\Plugin\VdbProvider\PineconeProvider-&gt;prepareFilters() #6 /var/www/html/web/modules/contrib/search_api/src/Entity/Server.php(483): Drupal\ai_search\Plugin\search_api\backend\SearchApiAiSearchBackend-&gt;search() #7 /var/www/html/web/modules/contrib/search_api/src/Query/Query.php(549): Drupal\search_api\Entity\Server-&gt;search() #8 /var/www/html/web/modules/contrib/ai/modules/ai_search/src/Plugin/AiFunctionCall/RagTool.php(130): Drupal\search_api\Query\Query-&gt;execute() #9 /var/www/html/web/modules/contrib/ai_agents/src/PluginBase/AiAgentEntityWrapper.php(886): Drupal\ai_search\Plugin\AiFunctionCall\RagTool-&gt;execute() #10 /var/www/html/web/modules/contrib/ai_agents/src/PluginBase/AiAgentEntityWrapper.php(409): Drupal\ai_agents\PluginBase\AiAgentEntityWrapper-&gt;executeTool() #11 /var/www/html/web/modules/contrib/ai_agents/src/PluginBase/AiAgentEntityWrapper.php(476): Drupal\ai_agents\PluginBase\AiAgentEntityWrapper-&gt;determineSolvability() #12 /var/www/html/web/modules/contrib/ai_agents/src/Plugin/AiFunctionCall/AiAgentWrapper.php(175): Drupal\ai_agents\PluginBase\AiAgentEntityWrapper-&gt;determineSolvability() #13 /var/www/html/web/modules/contrib/ai_agents/src/PluginBase/AiAgentEntityWrapper.php(886): Drupal\ai_agents\Plugin\AiFunctionCall\AiAgentWrapper-&gt;execute() #14 /var/www/html/web/modules/contrib/ai_agents/src/PluginBase/AiAgentEntityWrapper.php(409): Drupal\ai_agents\PluginBase\AiAgentEntityWrapper-&gt;executeTool() #15 /var/www/html/web/modules/contrib/ai_agents/src/PluginBase/AiAgentEntityWrapper.php(476): Drupal\ai_agents\PluginBase\AiAgentEntityWrapper-&gt;determineSolvability() #16 /var/www/html/web/modules/contrib/ai/modules/ai_assistant_api/src/Service/AgentRunner.php(48): Drupal\ai_agents\PluginBase\AiAgentEntityWrapper-&gt;determineSolvability() #17 /var/www/html/web/modules/contrib/ai/modules/ai_assistant_api/src/AiAssistantApiRunner.php(309): Drupal\ai_assistant_api\Service\AgentRunner-&gt;runAsAgent() #18 /var/www/html/web/modules/contrib/ai/modules/ai_chatbot/src/Controller/DeepChatApi.php(160): Drupal\ai_assistant_api\AiAssistantApiRunner-&gt;process() #19 [internal function]: Drupal\ai_chatbot\Controller\DeepChatApi-&gt;api() #20 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array() #21 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() #22 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer-&gt;executeInRenderContext() #23 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext() #24 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() #25 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw() #26 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel-&gt;handle() #27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session-&gt;handle() #28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle() #29 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength-&gt;handle() #30 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength-&gt;handle() #31 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache-&gt;pass() #32 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache-&gt;handle() #33 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle() #34 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle() #35 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState-&gt;handle() #36 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel-&gt;handle() #37 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel-&gt;handle() </pre><p>The problematic issue is in the function AiVdbProviderClientBase::isMultiple. The field being acted on is <strong>search_api_node_grants</strong>. </p> <pre>&nbsp; public function isMultiple(FieldInterface $field): bool {<br>&nbsp;&nbsp;&nbsp; [$fieldName] = explode(':', $field-&gt;getPropertyPath());<br>&nbsp;&nbsp;&nbsp; [, $entity_type] = explode(':', $field-&gt;getDatasourceId());<br>&nbsp;&nbsp;&nbsp; $fields = $this-&gt;entityFieldManager-&gt;getFieldStorageDefinitions($entity_type);<br>&nbsp;&nbsp;&nbsp; foreach ($fields as $field) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($field-&gt;getName() === $fieldName) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $cardinality = $field-&gt;getCardinality();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return !($cardinality === 1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return TRUE;<br>&nbsp; }</pre><p>Processing <code>$field-&gt;getDatasourceId()</code> results in <code>$entity_type</code> being set to null. It is probably more appropriate for parent methods to handle issues like this rather than being handled on a one-off basis by individual provider plugins.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>Install latest 1.1.x ai module.<br> Install ai_vdb_provider_pinecone 1.1.0-beta2.<br> Add an index backed by Pinecone with <strong>Content access</strong> and <strong>Entity status</strong> processors.<br> Add a agent that can use the RAG tool.<br> As a user who is not user 1 (it works fine for user 1 because user 1 I believe circumvents node grants entirely), chat with the agent and get it to use the RAG tool.<br> Verify you get the <code>$entity_type</code> is <strong>null</strong> and eventually get a <strong>PluginNotFoundException</strong>.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>I'm not sure the correct course of action other than improve error handling in the <code>isMultiple</code> method or somewhere else.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <h3 id="summary-ui-changes">User interface changes</h3> <h3 id="summary-api-changes">API changes</h3> <h3 id="summary-data-model-changes">Data model changes</h3> > Related issue: [Issue #3510985](https://www.drupal.org/node/3510985)
issue