PHP Error: Null check needed in RuleBase::getProvider() when no default provider is configured
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3511090. --> Reported by: [doxigo](https://www.drupal.org/user/1331334) Related to !491 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>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. </p> <pre>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<br>The website encountered an unexpected error. Try again later.<br><br>TypeError: Drupal\ai_automators\PluginBaseClasses\RuleBase::getProvider(): Return value must be of type string, null returned in Drupal\ai_automators\PluginBaseClasses\RuleBase-&gt;getProvider() (line 628 of modules/contrib/ai/modules/ai_automators/src/PluginBaseClasses/RuleBase.php).</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>- Install the AI module and enable the AI Automators submodule<br> - Do not configure any AI provider<br> - Try to use an AI Automator feature that uses the default_json provider with ScrapingBot without any active AI Provider</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Provide a meaningful error and make it possible for other modules to use it outside of the AI provider's scope</p>
issue