Module agent fails when enabling a module with missing dependencies, returning generic error in chatbot

Created on 14 August 2025, about 1 month ago

Problem/Motivation

When the module agent is instructed to enable a module that has a missing dependency, the process ends with an error in the chat interface.
Instead of gracefully handling the dependency issue, the chatbot fails and shows the error
"An error occurred while fetching messages. Please try again." while the logs report
"The chatbot had an error: We could not figure out which module you meant. Please specify better.".
This prevents the user from knowing the real cause (missing dependency) and breaks the conversation flow.

Steps to reproduce

  1. Set up a Drupal 11 installation with AI Agents enabled, or install the Drupal CMS AI recipe .
  2. Install the Sitemap module using:
    composer require 'drupal/sitemap:^2.0'

    but do not enable it.

  3. Open the Drupal agent chatbot.
  4. Type the prompt: Install "Sitemap book" module.
  5. When asked for confirmation, type yes.
  6. When it asks for confirmation to enable the "book" module, type yes.
  7. Observe that an error appears in the chat:
    "An error occurred while fetching messages. Please try again.".
  8. Check the recent log messages and see the error:
    "The chatbot had an error: We could not figure out which module you meant. Please specify better.".

Proposed resolution

  • Update the module agent logic to detect when a module has unmet dependencies before attempting to enable it.
  • If dependencies are missing, return a clear message to the user listing the required modules instead of producing a generic error.
  • Ensure the chatbot does not break the conversation flow when encountering dependency issues.

Remaining tasks

  • Implement dependency check logic in the module enable handler.
  • Add proper error handling and user messaging for missing dependencies.

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.2

Component

Code

Created by

🇮🇳India sijumpk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024