Avoid crashing the AI settings page if the default provider is not fully configured
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3476940. -->
Reported by: [codebymikey](https://www.drupal.org/user/3573206)
Related to !99
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When an API-based provider like OpenAI is not fully configured and is missing its API key, it can lead to a crash when the user visits the <code>/admin/config/ai/settings</code> page.</p>
<p>We should have some graceful error handling in place, so that the site builder is aware of what to do.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<ol>
<li>Install the OpenAI provider and have it configured as your default provider.</li>
<li>Remove the API key from the provider</li>
<li>Visiting the AI settings page will result in a crash because it can't load the API key.</li>
</ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Add more error handling to avoid nullpointer exceptions as well as catch more setup exceptions where relevant.</p>
<p>We can either check if the default provider is configured and usable before trying to fetch models from it, or we try to fetch the models and show the setup exception error message to the user.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Provide issue fork.</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>TBD</p>
issue