-
-
Notifications
You must be signed in to change notification settings - Fork 50
Description
The AssistantMessageNormalizer::normalize() method in vendor/symfony/ai-platform/src/Bridge/Anthropic/Contract/AssistantMessageNormalizer.php throws a TypeError when $data->toolCalls is null.
Error message
array_map(): Argument #2 ($array) must be of type array, null given
Root Cause
The current code uses $data->toolCalls ?? [] as a fallback, but this doesn't prevent the issue because array_map() is called regardless of whether toolCalls is null or not. The code assumes toolCalls will always be an array when it may be null.
Current Code (Problematic)
php'content' => array_map(static function (ToolCall $toolCall) {
return [
'type' => 'tool_use',
'id' => $toolCall->id,
'name' => $toolCall->name,
'input' => [] !== $toolCall->arguments ? $toolCall->arguments : new \stdClass(),
];
}, $data->toolCalls ?? []),