[AI Bundle] Fix unresolved Distance enum dependencies in configuration#1082
Merged
OskarStark merged 1 commit intosymfony:mainfrom Dec 8, 2025
Merged
Conversation
f5b7a84 to
e22fa7f
Compare
The options.php file was importing Distance enums from optional store bridge packages (postgres-store and redis-store) unconditionally. This caused errors when these packages weren't installed since PHP tries to resolve imports at parse time. The fix uses string values for the distance configuration instead of enum references, and converts them to enums in AiBundle.php only after verifying the package is installed via willBeAvailable().
e22fa7f to
ca96627
Compare
Contributor
|
Why do we still need the Require-Dev packages? |
Contributor
Author
|
Yes for the tests |
| ->info('Distance metric to use for vector similarity search') | ||
| ->enumFqcn(PostgresDistance::class) | ||
| ->defaultValue(PostgresDistance::L2) | ||
| ->values(['cosine', 'inner_product', 'l1', 'l2']) |
Contributor
There was a problem hiding this comment.
The only issue I see here is the fact that if a new case is added/removed in PostgresDistance, this config won't be up-to-date with it.
It will require to update the values (and add a conflict in the composer json ?).
But I don't see better solution for now. Unless removing the values restrictions and doing the value validation
- either in the AiBundle.php
- either in a callback here (but I'm not sure if it will avoid the unresolved enum...)
I wonder how it's dealed in other symfony packages, this should not be the first enum in an optional dependency isn't it ?
Contributor
Author
There was a problem hiding this comment.
PR welcome if you find something. To unblock, I merge this one in the current state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The options.php file was importing Distance enums from optional store bridge packages (postgres-store and redis-store) unconditionally. This caused errors when these packages weren't installed since PHP tries to resolve imports at parse time.
The fix uses string values for the distance configuration instead of enum references, and converts them to enums in AiBundle.php only after verifying the package is installed via willBeAvailable().