Gracefully handle missing AI provider configuration#523
Conversation
|
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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #523 +/- ##
=============================================
+ Coverage 70.72% 71.20% +0.47%
- Complexity 1144 1150 +6
=============================================
Files 67 67
Lines 5510 5563 +53
=============================================
+ Hits 3897 3961 +64
+ Misses 1613 1602 -11
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:
|
…gradations-no-provider
|
Thanks for the review @dkotter 🙇 . Addressed the feedbacks, please have a look whenever you get the chance. I'll add tests as well. |
dkotter
left a comment
There was a problem hiding this comment.
Tested and looks good to me, thanks for the work here! As mentioned, would be ideal to get E2E tests in place but once that's done this can be merged in
|
@dkotter updated the tests and added tests covering the changes. |
| * POST /ai-e2e/v1/credentials/seed — sets a dummy provider API key. | ||
| * POST /ai-e2e/v1/credentials/clear — removes it. | ||
| */ | ||
| function ai_e2e_register_credentials_endpoint() { |
There was a problem hiding this comment.
Can you explain the need for these endpoints? We already have helper functions that clear or set credentials using the UI so just wondering what benefit these provide over using that existing functionality?
There was a problem hiding this comment.
The REST endpoints exist because Playwright's afterAll and globalSetup hooks only receive requestUtils.
I tried using the existing clearConnectors in afterAll, but Playwright throws:
"context" and "page" fixtures are not supported in "afterAll" since they are created on a per-test basis.
Specifically we need REST for two cases:
global-setup.ts- seeds credentials before any browser launches (onlyrequestUtilsavailable, nopage)afterAllhooks insettings.spec.jsanddashboard.spec.js— these specs clear connectors during their run and need to restore credentials for subsequent specs, butafterAllonly receivesrequestUtils
There was a problem hiding this comment.
Before this PR, tests didn't need credentials since there was no frontend provider check. Now that ensureProvider() blocks AI actions when no provider is configured, every experiment test needs a valid API key. The global-setup seeds it upfront, and specs that clear connectors (settings, dashboard) re-seed in their afterAll via these REST endpoints.
What?
Closes #182
Adds graceful degradation across all AI experiments and features when no AI provider/connector is configured. Users now receive clear, actionable guidance instead of failed API calls or silent failures.
Why?
When no AI provider is configured, clicking any AI action button (Generate Title, Generate Alt Text, etc.) triggers a request which generated a Error Notice. Comment Moderation also silently fails on new comment. There is no guidance pointing users toward configuring a provider. This PR ensures users understand why an action is unavailable and know exactly where to go to fix it.
How?
Implemented a centralized provider availability architecture shared across all AI experiments.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 4.6
Used for: Implementation across multiple files following architectural decisions made collaboratively. All code was reviewed, iterated on, and validated by me.
Testing Instructions
Prerequisites
Ensure no AI connector is configured (remove API keys from Settings > Connectors). Enable all experiments in Settings.
Block Editor (Posts > Add New)
Media Library
Comments
With provider configured
Screenshots or screencast
Experiments:-

Comments Mod:-

Alt text from Media Library

Changelog Entry