PHP Error: Null check needed in AiAssistantApiRunner::setAssistant() when no default provider is configured

Created on 13 March 2025, 23 days ago

Problem/Motivation

Php error for null check found when no ai provider is enabled in AI chatbot block.

The website encountered an unexpected error. Try again later.
TypeError: Drupal\ai_assistant_api\AiAssistantApiRunner::setAssistant(): Argument #1 ($assistant) must be of type Drupal\ai_assistant_api\Entity\AiAssistant, null given, called in /var/www/html/modules/contrib/ai/modules/ai_chatbot/src/Plugin/Block/ChatFormBlock.php on line 240 in Drupal\ai_assistant_api\AiAssistantApiRunner->setAssistant() (line 164 of modules/contrib/ai/modules/ai_assistant_api/src/AiAssistantApiRunner.php).
Drupal\ai_assistant_api\AiAssistantApiRunner->setAssistant() (Line: 240)
Drupal\ai_chatbot\Plugin\Block\ChatFormBlock->build() (Line: 175)
Drupal\block\BlockViewBuilder::preRender()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 830)
Drupal\Core\Render\Renderer->doCallback() (Line: 387)
Drupal\Core\Render\Renderer->doRender() (Line: 203)
Drupal\Core\Render\Renderer->render() (Line: 120)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 119)
Drupal\Core\Render\Renderer->renderInIsolation() (Line: 146)
Drupal\Core\Render\Renderer->doRenderPlaceholder() (Line: 183)
Drupal\Core\Render\Renderer->renderPlaceholder() (Line: 715)
Drupal\big_pipe\Render\BigPipe->renderPlaceholder() (Line: 495)
Drupal\big_pipe\Render\BigPipe->Drupal\big_pipe\Render\{closure}()
Fiber->start() (Line: 502)
Drupal\big_pipe\Render\BigPipe->sendPlaceholders() (Line: 254)
Drupal\big_pipe\Render\BigPipe->sendContent() (Line: 116)
Drupal\big_pipe\Render\BigPipeResponse->sendContent() (Line: 395)
Symfony\Component\HttpFoundation\Response->send() (Line: 20)

Steps to reproduce

- Install the AI module and enable the AI Chatbot submodule
- Do not configure any AI provider
- Place the ai chatbot block in sidebar(any) region and visit the home page to view the chatbot

At the bottom of the page the php error shows up.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.1

Component

Other Submodules

Created by

🇮🇳India anjaliprasannan

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