Remove the credentials check from our is_enabled check#120
Remove the credentials check from our is_enabled check#120jeffpaul merged 1 commit intoWordPress:developfrom
is_enabled check#120Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #120 +/- ##
=============================================
- Coverage 29.37% 27.41% -1.97%
- Complexity 145 152 +7
=============================================
Files 14 14
Lines 885 901 +16
=============================================
- Hits 260 247 -13
- Misses 625 654 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What?
Remove the check for valid AI credentials when checking if an Experiment is enabled.
Why?
In #100, I added checks that run on our settings screen to verify we have valid AI credentials set and if not, show an error message alerting the user. This is helpful for users first setting things up, as this will help guide them through the process of adding AI credentials before turning on an Experiment.
In addition, I added a similar check when we run our
is_enabledcheck at the Experiment level. The goal here was to avoid showing an Experiment if the AI credentials are no longer valid (for instance, if someone revoked their API key).The issue I just realized is that our
is_enabledcheck runs basically everywhere, so by running our validation check there, we end up making an API request to the models endpoint on each page load, including the front-end. While this request runs pretty quickly, it's not great for performance to have that always run.How?
I considered two different approaches here to fix the problem:
is_enabledcheck and ensure we have proper error handling in each Experiment for situations where the AI credentials no longer workOpen to thoughts but after thinking it over, actually feels like a better user experience to go with the former. So the Experiment stays enabled, the UI is still available but when triggered, an error message is shown that let's the user know something went wrong and hopefully prompts them to go check their credentials.
Testing Instructions