Skip to content

Commit 07701c5

Browse files
committed
bug #963 [AI Bundle][VertexAI] factory get called with wrong arguments (franzwilding)
This PR was squashed before being merged into the main branch. Discussion ---------- [AI Bundle][VertexAI] factory get called with wrong arguments | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | License | MIT The vertex ai factory `create´method get called with one wrong "null" parameter. This removes the eventDispatcher, because it would be the 5th argument. Since method signature still is valid with null as 4th parameter, my `AiBundleTest::testExtensionLoadDoesNotThrow` test did not catch it. Commits ------- 2e9a9b7 [AI Bundle][VertexAI] factory get called with wrong arguments
2 parents 935821f + 2e9a9b7 commit 07701c5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/ai-bundle/src/AiBundle.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ private function processPlatformConfig(string $type, array $platform, ContainerB
507507
$httpClient,
508508
new Reference('ai.platform.model_catalog.vertexai.gemini'),
509509
new Reference('ai.platform.contract.vertexai.gemini'),
510-
null,
511510
new Reference('event_dispatcher'),
512511
])
513512
->addTag('ai.platform', ['name' => 'vertexai']);

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
class AiBundleTest extends TestCase
4949
{
50-
#[DoesNotPerformAssertions]
5150
public function testExtensionLoadDoesNotThrow()
5251
{
5352
$container = $this->buildContainer($this->getFullConfig());
@@ -59,6 +58,15 @@ public function testExtensionLoadDoesNotThrow()
5958
$platforms = $container->findTaggedServiceIds('ai.platform');
6059

6160
foreach (array_keys($platforms) as $platformId) {
61+
$def = $container->getDefinition($platformId);
62+
$factor = $def->getFactory();
63+
64+
if (\is_array($factor)) {
65+
$ref = new \ReflectionClass($factor[0]);
66+
$numArgs = $ref->getMethod($factor[1])->getNumberOfParameters();
67+
$this->assertGreaterThanOrEqual($numArgs, \count($def->getArguments()));
68+
}
69+
6270
try {
6371
$platformService = $container->get($platformId);
6472
$platformService->getModelCatalog();

0 commit comments

Comments
 (0)