From 46789a5a3a96c3b3f3095117d10f7d5bce189f75 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 2 Sep 2025 14:26:06 +0200 Subject: [PATCH] [AI Bundle] Remove unnecessary `normalizeKeys(false)` from `options.php` --- src/ai-bundle/config/options.php | 16 -------- .../DependencyInjection/AiBundleTest.php | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/ai-bundle/config/options.php b/src/ai-bundle/config/options.php index 9ac1b1e07..830a671ea 100644 --- a/src/ai-bundle/config/options.php +++ b/src/ai-bundle/config/options.php @@ -29,7 +29,6 @@ ->end() ->end() ->arrayNode('azure') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -95,7 +94,6 @@ ->end() ->end() ->arrayNode('agent') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -175,7 +173,6 @@ ->arrayNode('store') ->children() ->arrayNode('azure_search') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -188,7 +185,6 @@ ->end() ->end() ->arrayNode('cache') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -199,7 +195,6 @@ ->end() ->end() ->arrayNode('chroma_db') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -209,7 +204,6 @@ ->end() ->end() ->arrayNode('clickhouse') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -225,7 +219,6 @@ ->end() ->end() ->arrayNode('meilisearch') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -239,7 +232,6 @@ ->end() ->end() ->arrayNode('memory') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -248,7 +240,6 @@ ->end() ->end() ->arrayNode('milvus') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -263,7 +254,6 @@ ->end() ->end() ->arrayNode('mongodb') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -277,7 +267,6 @@ ->end() ->end() ->arrayNode('neo4j') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -295,7 +284,6 @@ ->end() ->end() ->arrayNode('pinecone') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -309,7 +297,6 @@ ->end() ->end() ->arrayNode('qdrant') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -322,7 +309,6 @@ ->end() ->end() ->arrayNode('surreal_db') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -340,7 +326,6 @@ ->end() ->end() ->arrayNode('typesense') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() @@ -355,7 +340,6 @@ ->end() ->end() ->arrayNode('indexer') - ->normalizeKeys(false) ->useAttributeAsKey('name') ->arrayPrototype() ->children() diff --git a/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php b/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php index 523e45405..7db3c4b25 100644 --- a/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php +++ b/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php @@ -264,6 +264,45 @@ public function testInMemoryStoreWithCustomStrategyCanBeConfigured() $this->assertSame('ai.store.distance_calculator.my_memory_store_with_custom_strategy', (string) $definition->getArgument(0)); } + public function testConfigurationWithUseAttributeAsKeyWorksWithoutNormalizeKeys() + { + // Test that configurations using useAttributeAsKey work correctly + // after removing redundant normalizeKeys(false) calls + $container = $this->buildContainer([ + 'ai' => [ + 'platform' => [ + 'azure' => [ + 'Test_Instance-123' => [ // Mixed case and special chars in key + 'api_key' => 'test_key', + 'base_url' => 'https://test.openai.azure.com/', + 'deployment' => 'gpt-35-turbo', + 'api_version' => '2024-02-15-preview', + ], + ], + ], + 'agent' => [ + 'My-Agent_Name.v2' => [ // Mixed case and special chars in key + 'model' => ['class' => 'Symfony\AI\Platform\Bridge\OpenAi\Gpt'], + ], + ], + 'store' => [ + 'mongodb' => [ + 'Production_DB-v3' => [ // Mixed case and special chars in key + 'database' => 'test_db', + 'collection' => 'test_collection', + 'index_name' => 'test_index', + ], + ], + ], + ], + ]); + + // Verify that the services are created with the exact key names + $this->assertTrue($container->hasDefinition('ai.platform.azure.Test_Instance-123')); + $this->assertTrue($container->hasDefinition('ai.agent.My-Agent_Name.v2')); + $this->assertTrue($container->hasDefinition('ai.store.mongodb.Production_DB-v3')); + } + private function buildContainer(array $configuration): ContainerBuilder { $container = new ContainerBuilder();