AiAutomatorEntityModifier::entityHasConfig() missing weight and worker_type causes crash on node save
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3577812. -->
Reported by: [jjchinquist](https://www.drupal.org/user/286806)
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>AiAutomatorEntityModifier::entityHasConfig() missing weight and worker_type causes crash on node save<br>
<strong>Short Description: </strong>entityHasConfig() builds automatorConfig array without weight/worker_type, causing PluginNotFoundException<br>
<strong>Check-in Date: </strong>03/08/2026<br>
<em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>In <code>AiAutomatorEntityModifier::entityHasConfig()</code> (ai_automators/src/AiAutomatorEntityModifier.php), the method builds the <code>automatorConfig</code> array from <code>field_name</code> and <code>plugin_config</code> keys only. It does not include <code>weight</code> or <code>worker_type</code> from the ai_automator config entity.</p>
<p>However, downstream code accesses those missing keys:</p>
<ul>
<li>Line ~97: <code>$a['automatorConfig']['weight']</code> — PHP warning "Undefined array key 'weight'"</li>
<li>Line ~100: <code>$b['automatorConfig']['weight']</code> — same warning</li>
<li>Line ~208: <code>$config['automatorConfig']['worker_type']</code> — causes a PluginNotFoundException when the empty string is passed as plugin ID</li>
</ul>
<p>This crashes node saves when AI Automator entities are configured for a content type. The error is:</p>
<p><code>Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for AiAutomatorFieldProcessManager are: queue, direct, field_widget_actions, batch</code></p>
<h4 id="summary-steps-reproduce">Steps to reproduce:</h4>
<ol>
<li>Install AI module 1.3.0-rc2 with ai_automators submodule enabled</li>
<li>Create an ai_automator config entity for a content type field (e.g. blog description)</li>
<li>Configure Field Widget Actions third-party settings on the form display for that field</li>
<li>Save/edit a node of that content type</li>
<li>Node save crashes with PluginNotFoundException</li>
</ol>
<p>AI modules enabled: ai, ai_automators<br>
AI provider: any (not provider-specific)<br>
Browser: any (server-side error)</p>
<h3 id="summary-proposed-resolution">Proposed resolution (suggested via AI)</h3>
<p>In <code>entityHasConfig()</code>, include <code>weight</code> and <code>worker_type</code> when building the automatorConfig array. Around line 183-188, after building from field_name and plugin_config, add:</p>
<p><code>$automatorConfig['weight'] = $field->get('weight');</code><br>
<code>$automatorConfig['worker_type'] = $field->get('worker_type');</code></p>
<h3 id="summary-remaining-tasks">Additional improvements</h3>
<ul>
<li>Add test coverage for entityHasConfig() including weight and worker_type</li>
</ul>
<h3>Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)</h3>
<p>Discovered while creating demo content for the Drupal AI 1.3.0 blog post. Affected version: 1.3.0-rc2.</p>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<p>[x] AI Assisted Issue<br>
This issue was generated with AI assistance, but was reviewed and refined by the creator.</p>
issue