CreateContentType tool not working

Created on 7 May 2025, 8 days ago

Problem/Motivation

Getting this error when testing the CreateContentType tool using tools explorer

TypeError: Cannot assign Symfony\Component\Validator\Constraints\Choice to property Symfony\Component\Validator\Constraints\Choice::$choices of type ?array in Symfony\Component\Validator\Constraint->__construct() (line 120 of /var/www/html/vendor/symfony/validator/Constraint.php)
#0 /var/www/html/vendor/symfony/validator/Constraints/Choice.php(86): Symfony\Component\Validator\Constraint->__construct()
#1 /var/www/html/web/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php(27): Symfony\Component\Validator\Constraints\Choice->__construct()

//

#14 /var/www/html/web/modules/contrib/ai/modules/ai_api_explorer/src/Plugin/AiApiExplorer/ToolsExplorer.php(304): Drupal\ai\Base\FunctionCallBase->validateContexts()
#15 /var/www/html/web/modules/contrib/ai/modules/ai_api_explorer/src/Form/AiApiExplorerForm.php(82): Drupal\ai_api_explorer\Plugin\AiApiExplorer\ToolsExplorer->getResponse()

Steps to reproduce

Enable AI API Explorer and try to create a content type using this tool

Proposed resolution

Updating 'constratints' section of 'preview_mode' under context defintion fixes the issue

    'preview_mode' => new ContextDefinition(
      data_type: 'integer',
      label: new TranslatableMarkup("Preview Mode"),
      description: new TranslatableMarkup("Whether preview mode is enabled or not. 0 is disabled, 2 is required, 1 is optional."),
      default_value: DRUPAL_OPTIONAL,
      constraints: [
        'AllowedValues' => [DRUPAL_REQUIRED, DRUPAL_OPTIONAL, DRUPAL_DISABLED],
      ],
    ),

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.1

Component

Code

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