[issue #660] feat: Update generalised error message for all features#759
[issue #660] feat: Update generalised error message for all features#759SohamPatel46 wants to merge 6 commits into
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 #759 +/- ##
=============================================
+ Coverage 75.50% 75.79% +0.29%
- Complexity 2086 2117 +31
=============================================
Files 99 99
Lines 8626 8710 +84
=============================================
+ Hits 6513 6602 +89
+ Misses 2113 2108 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| /** | ||
| * Checks if any configured connector is unapproved and returns a corresponding WP_Error if so. | ||
| * | ||
| * @since 1.1.0 |
There was a problem hiding this comment.
All @since statements need to be set to x.x.x
What?
Closes #660
Implements a centralized, context-aware error message mapping in the WordPress REST API when AI requests (e.g. "Generate Title", "Generate Excerpt") are blocked by the Connector Approvals feature.
Why?
Previously, when the Connector Approvals feature blocked the caller (
wp-ai), the user was shown a generic error notice: "Title generation failed. Please ensure you have a connected provider that supports text generation." This led users to believe that their API keys or connected providers were broken when the feature was actually just awaiting approval in the WordPress admin panel.Using a centralized server-side approach via a REST dispatch filter ensures that all features display clean, translated, and context-aware instructions explaining how to authorize the connector under
Tools > Connector Approvals, without duplicating approval-checking code across individual feature controllers or frontend JS files.How?
rest_post_dispatchfilter inside the Connector_Approval experiment class.wpai_connector_not_approvedcode, it intercepts the error, parses the Ability ID from the route path, and maps it to a context-aware prefix (e.g. "Title generation failed.", "Excerpt generation failed.").ensure_text_generation_supported()andensure_image_generation_supported()in Abstract_Ability.wpai_connector_not_approvedinstead of the genericunsupported_modelerror.Use of AI Tools
Testing Instructions
Screenshots or screencast
Changelog Entry
Fixed - Display a clear, context-aware error notice during Ability execution when the configured AI connector is pending administrator approval.