Type mismatch for moduleHandler service in dependency injection in AgentHelper.php with hook_event_dispatcher module

Created on 3 June 2025, 2 days ago

Problem/Motivation

If the hook_event_dispatcher module is enabled in Drupal (10.3.10), it is throwing an error as given below

TypeError: Drupal\ai_agents\Service\AgentHelper::__construct(): Argument #2 ($moduleHandler) must be of type Drupal\Core\Extension\ModuleHandler, Drupal\hook_event_dispatcher\HookEventDispatcherModuleHandler given, called in /var/www/html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 261 in Drupal\ai_agents\Service\AgentHelper->__construct() (line 98 of modules/contrib/ai_agents/src/Service/AgentHelper.php).

Proposed resolution

  • Removed the strict type from AgentHelper.php constructor
  • Added a service alias in ai_agent.services.yml
  • Updated the arguments for ai_agents.agent_helper in services.yml to use @ai_agent.module_handler_adapter as second argument.
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India sharma.amitt16 Delhi

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024