Skip to content

Commit 78c791c

Browse files
committed
[AI Bundle] Skip processing empty store configurations
Fix the issue where configuring only one store type (e.g., chromadb) would cause errors for other unconfigured store types. The configuration system populates all store types with empty arrays by default, and the processStoreConfig method was checking for package availability before checking if any stores were actually configured. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent a5a34a8 commit 78c791c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/ai-bundle/src/AiBundle.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,10 @@ private function processAgentConfig(string $name, array $config, ContainerBuilde
979979
*/
980980
private function processStoreConfig(string $type, array $stores, ContainerBuilder $container, array &$setupStoresOptions): void
981981
{
982+
if ([] === $stores) {
983+
return;
984+
}
985+
982986
if ('azuresearch' === $type) {
983987
if (!ContainerBuilder::willBeAvailable('symfony/ai-azure-search-store', AzureSearchStore::class, ['symfony/ai-bundle'])) {
984988
throw new RuntimeException('Azure Search store configuration requires "symfony/ai-azure-search-store" package. Try running "composer require symfony/ai-azure-search-store".');

src/ai-bundle/tests/DependencyInjection/AiBundleTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,25 @@ public function testChromaDbStoreCanBeConfigured()
717717
$this->assertTrue($container->hasAlias('Symfony\AI\Store\StoreInterface'));
718718
}
719719

720+
#[TestDox('Configuring only one store type does not require packages for other store types')]
721+
public function testConfiguringOnlyOneStoreTypeDoesNotRequireOtherStorePackages()
722+
{
723+
$container = $this->buildContainer([
724+
'ai' => [
725+
'store' => [
726+
'chromadb' => [
727+
'my_store' => [
728+
'collection' => 'test_collection',
729+
],
730+
],
731+
],
732+
],
733+
]);
734+
735+
$this->assertTrue($container->hasDefinition('ai.store.chromadb.my_store'));
736+
$this->assertFalse($container->hasDefinition('ai.store.azuresearch.my_store'));
737+
}
738+
720739
public function testChromaDbStoreWithCustomClientCanBeConfigured()
721740
{
722741
$container = $this->buildContainer([

0 commit comments

Comments
 (0)