Canvas AI: Agent should pass values to image props correctly

Created on 3 September 2025, 14 days ago

Overview

When an SDC has an image prop which is marked as required, its now not possible for AI Agent to use this component in it's reponse after ๐Ÿ“Œ Allow AI to validate changes before publishing Active landed.

Steps to recreate this issue
Enable canvas ai and AI API explorer and canvas_test_sdc modules
Go to '/admin/config/ai/explorers/tools_explorer?tool=canvas_ai%3Aset_component_structure'
Give the following YML as 'component_structure' input and click Run function

reference_nodepath: [0, 0]
placement: above
components:
  - sdc.canvas_test_sdc.card:
      props:
        heading: "Delicious Cookie Selection"
        content: "Indulge your sweet tooth with our mouthwatering variety of freshly baked cookies! Choose from chocolate chip, oatmeal raisin, snickerdoodle, and moreโ€”all made in-house every morning."
        footer: "Order today for same-day pickup or delivery!"
        loading: eager
        sizes: "auto 50vw"
        image:
          src: "https://example.com/customer1.jpg"
          alt: "Happy customer enjoying ice cream"
          width: 640
          height: 427

There will be a validation error

'Failed to process layout data: Component validation errors:
 components.0.[sdc.canvas_test_sdc.card].props.image:
    The property image is required.'

The error says image prop is required, even if src, alt etc are provided. This triggeres the agent to regenerate the yml again and it will eventually fail with message 'The task is not solvable'

I did some debugging. When the image field input values are processed by Drupal\canvas\Plugin\Canvas\ComponentSource\GeneratedFieldExplicitInputUxComponentSourceBase::validateComponentInput method, the following LengthException exception occurs for some reason.

''Field item list length is a lie, because it contains items considered empty by the field type. This is acceptable when previewing and auto-saving, but unacceptable when saving."

The validateinput method then unsets the image input value, which could be triggering 'Image prop is required' exception.

Proposed resolution

User interface changes

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

AI

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Akhil Babu Chengannur

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