PHP Error: Null check needed in RuleBase::getProvider() when no default provider is configured

Created on 5 March 2025, 4 days ago

Problem/Motivation

I was testing the ScrapingBot module and when using the AI Automator module without configuring any AI provider, the module throws PHP errors instead of providing a meaningful error message.

Warning: Trying to access array offset on null in /var/www/html/web/modules/contrib/ai/modules/ai_automators/src/PluginBaseClasses/RuleBase.php on line 620
The website encountered an unexpected error. Try again later.

TypeError: Drupal\ai_automators\PluginBaseClasses\RuleBase::getProvider(): Return value must be of type string, null returned in Drupal\ai_automators\PluginBaseClasses\RuleBase->getProvider() (line 628 of modules/contrib/ai/modules/ai_automators/src/PluginBaseClasses/RuleBase.php).

Steps to reproduce

- Install the AI module and enable the AI Automators submodule
- Do not configure any AI provider
- Try to use an AI Automator feature that uses the default_json provider with ScrapingBot without any active AI Provider

Proposed resolution

Provide a meaningful error and make it possible for other modules to use it outside of the AI provider's scope

🐛 Bug report
Status

Active

Version

1.1

Component

AI Automators

Created by

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