[Tracker]
Update Summary: [One-line status update for stakeholders]
Short Description: [One-line issue summary for stakeholders]
Check-in Date: MM/DD/YYYY
Metadata is used by the AI Tracker. Docs and additional fields here.
[/Tracker]
Problem/Motivation
Renaming an image filename with AI automator in a website where Drupal Canvas is present produces an error.
InvalidArgumentException: Property value is unknown. in Drupal\Core\TypedData\TypedDataManager->getPropertyInstance() (line 204 of /var/www/html/web/core/lib/Drupal/Core/TypedData/TypedDataManager.php).
#0 /var/www/html/web/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php(123): Drupal\Core\TypedData\TypedDataManager->getPropertyInstance(Object(Drupal\canvas\Plugin\Field\FieldTypeOverride\ImageItemOverride), 'value', NULL)
#1 /var/www/html/web/modules/contrib/ai/modules/ai_automators/src/Plugin/FieldWidgetAction/AutomatorBaseAction.php(308): Drupal\Core\TypedData\Plugin\DataType\Map->get('value')
#2 /var/www/html/web/modules/contrib/ai/modules/ai_automators/src/Plugin/FieldWidgetAction/AutomatorBaseAction.php(270): Drupal\ai_automators\Plugin\FieldWidgetAction\AutomatorBaseAction->saveFormValues(Array, 'field_media_ima...', Object(Drupal\media\Entity\Media), 0)
#3 /var/www/html/web/modules/contrib/ai/modules/ai_automators/src/Plugin/FieldWidgetAction/ImageFilename.php(52): Drupal\ai_automators\Plugin\FieldWidgetAction\AutomatorBaseAction->populateAutomatorValues(Array, Object(Drupal\Core\Form\FormState), 'field_media_ima...', 0)
#4 /var/www/html/web/modules/contrib/ai/modules/ai_automators/src/Plugin/FieldWidgetAction/ImageFilename.php(45): Drupal\ai_automators\Plugin\FieldWidgetAction\ImageFilename->populateAutomatorValues(Array, Object(Drupal\Core\Form\FormState), 'field_media_ima...', 0)
#5 [internal function]: Drupal\ai_automators\Plugin\FieldWidgetAction\ImageFilename->aiAutomatorsAjax(Array, Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request))
#6 /var/www/html/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(69): call_user_func_array(Array, Array)
Steps to reproduce (required for bugs, but not feature requests)
Enable Media
Enable Canvas
Enable Ai Automator
Adding an automator to rename filename in the image field inside Media Image type with Field Widget
When clicking the button to renamem we see an error



Proposed resolution
Remaining tasks
Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | test issue.gif | 234.74 KB | jesus_md |
| #20 | 08-ai-config.png | 64.04 KB | ajv009 |
| #20 | 07-error-detail.png | 449.19 KB | ajv009 |
| #20 | 06-watchdog-log.png | 114.48 KB | ajv009 |
| #20 | 05-error-triggered.png | 74.93 KB | ajv009 |
Issue fork ai-3561693
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
Comment #2
marcus_johansson commentedComment #3
marcus_johansson commentedComment #4
arianraeesi commentedComment #5
arianraeesi commentedThis issue is for onboarding new contributors
Comment #6
arianraeesi commentedComment #7
ferran_bosch commentedComment #8
ferran_bosch commentedComment #9
ajv009 commentedI am going to take a quick stab at this... Trying to reproduce...
Comment #10
ajv009 commented`AutomatorBaseAction::saveFormValues()` calls `$item->get('value')` on image field items, but image fields don't have a `value` property (they have `target_id`, `alt`, `title`, `width`, `height`). This causes `InvalidArgumentException: Property value is unknown.`
Additionally this is not a canvas specific issue, as the core ImageItem itself lacks the `value` and canvas ImageItemoverride inherits ImageItem
Comment #12
ajv009 commented.
Comment #13
ajv009 commentedComment #17
ajv009 commentedMy bad its been some time I did a proper d.o contrib, I hope the steps i followed above is fine.
I mistakenly bumped up the version earier but I just moved it back to the original version mentioned in the issue.
And yeah here is the issue being reproduced:
and here is the post fix ss:
Root Cause:
AutomatorBaseAction::saveFormValues()calls$item->get('value')on image field items, but image fields don't have avalueproperty (they havetarget_id,alt,title,width,height). This causesInvalidArgumentException: Property value is unknown.Not Canvas-specific. Core
ImageItemalso lacksvalue. Canvas'sImageItemOverrideinherits fromImageItemand doesn't change the property set. Compare withImageAltTextwhich works fine because it uses$formElementProperty = 'alt'— a valid image property.Fix: Add a property existence check at the top of
AutomatorBaseAction::saveFormValues():The early return is correct here because
LlmRewriteImageFilename::storeValues()already renames and saves the File entity directly — there's no field item property to read back.Tested: Reproduced the exact error with Canvas + AI Automators on a Media Image form. After the fix, clicking "Automator Image Filename Rewrite" no longer crashes. All text-based field types (
string,text,list_string,boolean,email, etc.) are unaffected — they havevaluein their property definitions and continue through the normal code path.MR: https://git.drupalcode.org/project/ai/-/merge_requests/1288
Steps to reproduce
ai_automatorsandcanvasmodules (drush en ai_automators canvas)field_media_imageusing the "LLM Rewrite Image Filename" rulefield_media_imagewidget, enable the "Image Filename" field widget action and select your automatorInvalidArgumentException: Property value is unknown.inAutomatorBaseAction::saveFormValues()(usually a ajax console error)Steps to verify the fix doesn't break other fields
titleor a plain text field)valueand pass the property check)AI usage
This issue was generated with AI assistance, but was reviewed and refined by the creator.
This code was mainly generated by a human, with AI auto-completing or parts AI generated, but under full human supervision.
This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.
This code was generated by an AI and has only been functionally tested.
Comment #18
cadence96 commentedComment #19
cadence96 commentedHi @ajv009, I've tested this issue multiple times, but it doesn't seem to work for me. Maybe I'm doing something wrong. I've attached a video showing my test. The filename doesn't change, and no error message is displayed.
Please let me know if I need to enable or add any additional settings to make it work.
Comment #20
ajv009 commentedHey @cadence96, thanks for testing this out! I went back and reproduced the issue again from scratch on a clean Drupal 11.3.5 + AI
1.2.x-dev(9831ffd) + Canvas1.3.1setup using ddev, and I can confirm the originalInvalidArgumentExceptionis definitely still there without the fix:About your test where the filename doesn't change and no error is displayed — I think what's happening is the fix in MR !1288 is actually working (no more crash!), but you might not have an LLM provider configured yet. Without one, the automator runs but has nothing to generate a new filename with, so it just silently does nothing. Could you check
/admin/config/aiand make sure you have a provider set up for the "chat" type? The watchdog log might show something like "No provider set for the LLM type chat".Also, one thing that tripped me up during setup — the way the automator config entity is created matters a lot. If you used the dedicated add form at
/admin/config/ai/ai-automators/ai-automator/add, that form is actually broken on 1.2.x-dev (crashes withTyped property AiAutomator::$entity_type must not be accessed before initialization— related to #3558728: Add AI Automator field form breaks if fields not available in any bundle which covers the samecalculateDependencies()crash for$field_name). The proper way to set it up is through the field config form: Structure → Media types → Image → Manage fields → field_media_image → Edit, and enable the automator from there. That path properly populates theplugin_configarray which the runtime code depends on.If you created the automator a different way (drush, config import, etc.), the
plugin_configmight be empty, which causes a different error —PluginNotFoundException: The "" plugin does not exist— that can also look like "nothing happens" from the UI side. This was also reported in #3577812: AiAutomatorEntityModifier::entityHasConfig() missing weight and worker_type causes crash on node save (closed as cannot reproduce, but it does happen with programmatically created automators).Here's what worked for me to reproduce end-to-end:
ddev composer create drupal/recommended-project:^11ddev composer require drush/drush drupal/ai:1.2.x-dev drupal/canvas drupal/tokenddev drush site:install -y && ddev drush en media media_library ai_automators canvas field_widget_actions -y/media/add/imageand click the buttonCould you give it another try with those steps and let me know if you see the same results? If the fix is applied and you have a provider configured, it should work — the filename should change and no error should appear.
The root cause is the same as I described in comment #11 —
saveFormValues()tries to read'value'from image field items, but image fields don't have that property. The early return in the fix is safe becauseLlmRewriteImageFilename::storeValues()already handles the rename directly on the File entity.Transparency note: This comment was synthesized — the issue research, environment setup, and reproduction were done using Claude Code (autonomous AI tooling). I personally supervised the entire process as part of an ongoing experiment on the reliability of using autonomous kanbans for contribution workflows. No intent to demean anyone's effort here — everyone's work on this issue has been valuable. If I'm not doing something right process-wise, please flag it and I'll course-correct.
Comment #21
a.dmitriiev commentedMaybe instead of doing the potentially dangerous change in the Automator Base class, it makes more sense to fix it in ImageFilename class instead?
Either by setting the correct field property, changing this:
to
or alternatively override the
saveFormValuesmethod in ImageFilename class like:Do you agree?
I think that fixing base class is also a good idea, but it might potentially bring some problems with other plugins (I am not saying that it will, but might be somehow).
Comment #22
ajv009 commentedHey @a.dmitriiev, fair, but I went and audited all 12 plugins extending
AutomatorBaseActionto see if the base class change could cause trouble. Here's what I found:Every existing plugin sets a
$formElementPropertythat actually exists on its target field type ('value'for text/number/boolean/list/email,'alt'for ImageAltText,'target_id'for entity_reference,'uri'for link,'summary'for text_with_summary). The only plugin where the property doesn't match isImageFilename, which sets'value'on an image field. So the defensive check in the base class would only trigger forImageFilenametoday, and wouldn't change behavior for anything else.On your two suggestions:
$formElementProperty = 'target_id'would pass the property existence check, but thensaveFormValues()would try to write to$form[...]['target_id']['#value'], which doesn't exist as a form element in image widgets. The image widget doesn't exposetarget_idas an editable input, so that could cause a different error.saveFormValues()to justreturn $form[$form_key]works and makes it explicit that this plugin doesn't need to write anything back. I mean, that's good, I think.I think doing both could be the cleanest path: override
saveFormValues()inImageFilenameso the intent is clear, and keep the base class check as a safety net for future plugins that might hit the same mismatch. But I'm also fine with just the local fix if you feel strongly about keeping the base class untouched. I might not be the right voice here as I am just reviewing what was raised or asked in the issue...Unrelated thing I noticed while auditing: a few plugins use
static::FORM_ELEMENT_PROPERTY(the constant, always'value') instead of$this->formElementProperty(the instance property) in theiraiAutomatorsAjax()methods. For example,SummaryTextareaWithSummarysets$formElementProperty = 'summary'but its AJAX handler uses the constant'value'on line 37. Same thing inClassificationOptionsSelect('target_id'vs constant'value', line 32). Compare withImageAltTextandImageFilenamewhich correctly use$this->formElementProperty. Not causing a crash right now since$form_keyis read from index 0 of$array_parents, but it does build incorrect form paths. Probably worth a separate issue if it's not already tracked.Transparency note: The plugin audit was done with Claude Code. I verified the findings by reading some plugin files. If anything looks off, happy to be corrected.
Comment #23
a.dmitriiev commentedThere will be a change in the Base class here #3577050: Generalize behaviour of FWA with Automators soon, that is why I would like to keep it untouched, maybe include the fix with additional checks in that issue instead.
Comment #24
ajv009 commentedHmm, so the issue you mentioned basically fixes this on 1.3.x ...
In that case, yeah, this might be TOO big... might as well bring the change to local imageFilename temporarily, I suppose...
makes sense, I guess...
on it...
Comment #25
ajv009 commentedComment #26
jesus_md commentedTested on:
- Drupal 11.3.5
- AI 1.2.x-dev (branch 3561693-Conflict-Canvas-and-Rename-filename-Automator, commit df1439c9)
- Canvas 1.3.2
- PHP 8.4
Without the fix, clicking the "Automator Image Filename Rewrite" button throws InvalidArgumentException: Property value is unknown in AutomatorBaseAction::saveFormValues() as described.
Then with the fix applied, the button no longer crashes. The override of saveFormValues() in ImageFilename returning early is the correct approach since LlmRewriteImageFilename::storeValues() already handles the rename directly on the File entity.
Comment #27
jesus_md commentedComment #28
jesus_md commentedComment #35
a.dmitriiev commentedThank you! Merged and cherry picked to all active branches.
Let's continue with the fix to base class in #3577050: Generalize behaviour of FWA with Automators
Comment #39
arianraeesi commented