Problem/Motivation

AI Media reads the default provider of each operation from ai.settings default_providers. When that provider's module is not installed (uninstalled later, or the config imported before the module), AiMediaGeneratorBase::defaultFor() still returns the default, so isConfigured() is TRUE: the editor is offered "Generate with AI", presses Generate, and gets "This could not be made. Try again." The paid-request line under the button shows the raw plugin id ("Each press is a paid request to openai.") because providerLabel() has no definition to read. The log carries PluginNotFoundException: The "openai" plugin does not exist.

Steps to reproduce

  1. Set default_providers.text_to_image to a provider whose module is not enabled (or uninstall the provider module after setting it).
  2. As a content editor, open Add media > Image: the Upload / Generate with AI switch is offered.
  3. Describe an image and press Generate image: "This could not be made. Try again."

Proposed resolution

defaultFor() returns NULL when AiProviderPluginManager::hasDefinition() is FALSE for the configured provider id. The generator then counts as not set up: no switch for editors, and administrators read the "not set up" message naming the operation. Kernel test in ErrorMessagesTest.

Remaining tasks

  • ✅ File an issue
  • ❌ Addition/Change/Update/Fix
  • ❌ Testing to ensure no regression
  • ❌ Automated unit/functional testing coverage
  • ➖ Developer Documentation support
  • ➖ User Guide Documentation support
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ❌ Reviewed by a human
  • ❌ Code review by maintainers
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ✅ Update Release Notes
  • ✅ Release

User interface changes

  • With a default provider whose module is missing, the Generate switch is not offered and administrators see the "not set up" message instead of a failed generation.

Before: the editor is offered Generate with AI, presses Generate and gets "This could not be made. Try again."; the paid-request line names the raw plugin id.

Add Image with the Generate with AI switch selected, the description filled, and the red message This could not be made. Try again. under it

After, as a content editor: the switch is not offered and the plain upload form shows.

Add Image showing only the upload field, no Generate with AI switch

After, as an administrator: the not set up message names the operation and links to the AI settings.

Add Image with the warning Image generation is not set up. Choose a default provider for text_to_image in the AI settings.

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • A default provider whose module is not installed now counts as not set up instead of offering a Generate that fails.

AI-Generated: Yes

Issue fork ai_media-3634660

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

rajab natshah’s picture

  • rajab natshah committed 0255e080 on 1.0.x
    fix: #3634660 Count a default provider whose module is not installed as...
rajab natshah’s picture

Issue summary: View changes
Status: Active » Fixed
Issue tags: +ai_media-1.0.0-rc1

✅ Released ai_media-1.0.0-rc1

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.