Skip to content

Replace the error message the AI Client returns with a more specific one if image requests fail#332

Open
dkotter wants to merge 5 commits intoWordPress:developfrom
dkotter:update/image-refinement-error-message
Open

Replace the error message the AI Client returns with a more specific one if image requests fail#332
dkotter wants to merge 5 commits intoWordPress:developfrom
dkotter:update/image-refinement-error-message

Conversation

@dkotter
Copy link
Copy Markdown
Collaborator

@dkotter dkotter commented Mar 20, 2026

What?

Ensure we show a more understandable error message if image generation / refinement / editing fails.

Why?

At the moment, image generation is supported by the Google and OpenAI provider plugins but image editing / refinement is only supported by Google. If you only have OpenAI connected, you can generate an image but if you then try and refine that image, you'll receive an error message.

Also, if you have no providers connected that support image generation and you turn on the image generation experiment, the UI is still available to use (which this is how all of our experiments currently work). If you try and generate an image you will get an error message.

These messages come from the AI Client and we just capture and display them. But the error messages aren't super specific and don't make it completely clear what the actual problem is, so this PR replaces those errors with more specific ones.

How?

If an error happens when we make an image generation request, replace the error message the AI Client returns from:

No models found that support image_generation for this prompt.

to

Image generation failed. Please ensure you have a connected provider that supports image generation.

If an error happens when we make an image edit request, replace the error message the AI Client returns from:

No models found that support image_generation for this prompt.

to

Image refinement failed. Please ensure you have a connected provider that supports image refinement, not just image generation.

Use of AI Tools

None

Testing Instructions

  1. Check out this PR
  2. Install the OpenAI Provider plugin
  3. Activate that and configure it properly
  4. Turn on image generation and generate an image
  5. Click the Refine button after generating and enter a refinement prompt
  6. Ensure you get the more specific error message now
  7. Disable the OpenAI Provider
  8. Try and generate an image
  9. Ensure you get a specific error message

Screenshots

Error message that shows when a provider doesn't support image generation Error message that shows when a provider doesn't support image editing Open WordPress Playground Preview

… error message the AI Client returns with something more specific
@dkotter dkotter added this to the 0.7.0 milestone Mar 20, 2026
@dkotter dkotter self-assigned this Mar 20, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 20, 2026

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

jeffpaul
jeffpaul previously approved these changes Mar 20, 2026
@jeffpaul jeffpaul moved this to Needs review in WordPress AI Planning & Roadmap Mar 20, 2026
@dkotter dkotter changed the title Replace the error message the AI Client returns with a more specific one if image refinement fails Replace the error message the AI Client returns with a more specific one if image requests fail Mar 20, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.76%. Comparing base (32c5e2d) to head (c39db2c).

Files with missing lines Patch % Lines
includes/Abilities/Image/Generate_Image.php 0.00% 5 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #332      +/-   ##
=============================================
- Coverage      57.85%   57.76%   -0.10%     
- Complexity       615      617       +2     
=============================================
  Files             46       46              
  Lines           3165     3170       +5     
=============================================
  Hits            1831     1831              
- Misses          1334     1339       +5     
Flag Coverage Δ
unit 57.76% <0.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@jeffpaul jeffpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, feel free to merge when ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

2 participants