- Issue created by @Akhil Babu
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()
Enable AI API Explorer and try to create a content type using this tool
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],
],
),
Active
1.1
Code