[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 3 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 76.24% 76.57% +0.32%
- Complexity 1765 1796 +31
=============================================
Files 85 85
Lines 7591 7675 +84
=============================================
+ Hits 5788 5877 +89
+ Misses 1803 1798 -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:
|
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.