Field Widget Action throws error when associated Automator is removed from field

Created on 24 July 2025, 13 days ago

Problem/Motivation

When an AI automator is removed from a field's configuration but its associated Field Widget Actions are left in place, triggering the action causes a fatal error.

UI Error Message:
Oops, something went wrong. Check your browser's developer console for more details.

Recent log entry:
Error: Call to a member function get() on null in Drupal\ai_automators\Plugin\FieldWidgetAction\AutomatorBaseAction->populateAutomatorValues() (line 245 of /modules/contrib/ai/modules/ai_automators/src/Plugin/FieldWidgetAction/AutomatorBaseAction.php)

This occurs because the field widget action still tries to reference a removed automator.

Steps to reproduce (required for bugs, but not feature requests)

  1. Go to Manage fields for the Basic page content type.
  2. Add a new field of type Plain text called Label.
  3. In the field settings:
    • Check Enable AI Automator
    • Select LLM: Text for AI Automator Type
    • Set Automator Input Mode to Base Mode
    • Select Title for Automator Base Field
    • Set Automator Prompt to: Return only the word "Hello"
  4. Save the field settings.
  5. Go to the Manage form display tab.
  6. Ensure the Label field uses the Textfield widget.
  7. Click the gear icon for the widget settings.
  8. Expand the Field Widget Actions section and:
    • Add an action of type Automator Text Suggestion
    • Enable the Enable Automators checkbox
    • Set Button label to Generate
    • Set Automator to use for suggestions to Label Default
  9. Go to Add Basic page, enter a title, and click Generate → it works fine.
  10. Return to the Label field settings and uncheck Enable AI Automator to disable the automator.
  11. Do not remove or update the widget action.
  12. Return to the Add Basic page form and click Generate again.

Result: UI error and PHP fatal error.

Expected: Widget action should handle missing automator gracefully or not be available once automator is removed.

Proposed resolution

  • When an automator is removed from a field, automatically remove or disable the associated Field Widget Actions.
  • Alternatively, update the widget action plugin to validate the existence of the automator before attempting to access it.

Remaining tasks

  • Fix the issue so that field widget actions do not cause errors when the associated automator is removed.

Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)

🐛 Bug report
Status

Active

Version

1.2

Component

AI Automators

Created by

🇮🇳India sijumpk

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