Improve handling when no key/missing key is configured
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3560493. -->
Reported by: [mxr576](https://www.drupal.org/user/315522)
Related to !22
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>If the module is installed and <code>gemini_privider.settings:api_key === ''</code> (in other words a Key entity with the stored id does not exist) or the <code>$key->getKeyValue()</code> returns <code>null</code> then some AI admin pages (for example, <code>admin/config/ai/settings</code>) explodes with the following error:</p>
<p><code>TypeError: Drupal\gemini_provider\Plugin\AiProvider\GeminiProvider::loadApiKey(): Return value must be of type string, null returned in Drupal\gemini_provider\Plugin\AiProvider\GeminiProvider->loadApiKey() (line 311 of modules/contrib/gemini_provider/src/Plugin/AiProvider/GeminiProvider.php). </code></p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<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>
issue