fix: enable DI for FeatureOptInService#13
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| export const moduleLoader: ModuleLoader = { | ||
| token: moduleToken, | ||
| loadModule, | ||
| }; |
There was a problem hiding this comment.
Module exports wrong token causing DI lookup failures
High Severity
The moduleLoader exports moduleToken instead of token. The bindModuleToClassOnToken function binds the FeaturesRepository class to token (FLAGS_DI_TOKENS.FEATURES_REPOSITORY), but the exported moduleLoader.token is set to moduleToken (FLAGS_DI_TOKENS.FEATURES_REPOSITORY_MODULE). When getFeaturesRepository() calls container.get(featuresRepositoryModuleLoader.token), it will fail to find the service because it's looking up the wrong token.
| const featuresRepository = new FeaturesRepository(prisma); | ||
| const service = new FeatureOptInService(featuresRepository); | ||
| const featuresRepository = getFeaturesRepository(); | ||
| const service = getFeatureOptInService(); |
There was a problem hiding this comment.
Test uses separate repository instances breaking cache invalidation
Medium Severity
The test refactoring creates two separate FeaturesRepository instances: one from getFeaturesRepository() stored in featuresRepository, and another internally created by getFeatureOptInService() as a dependency of service. The clearFeaturesCache(featuresRepository) call in setupFeature clears the cache of the wrong instance—the service's internal repository cache remains stale. Before this change, the same instance was explicitly shared between featuresRepository and service.
Benchmark PR from agentic-review-benchmarks#13
Note
Introduces DI wiring for feature opt-in and flags, replacing direct instantiation with container-resolved services.
FeatureOptInServiceandFeaturesRepository(modules/FeatureOptInService,modules/FeaturesRepository,containers/FeatureOptInService,containers/FeaturesRepository), plus new token setsFLAGS_DI_TOKENSandFEATURE_OPT_IN_DI_TOKENSmerged intoDI_TOKENSIFeatureOptInServiceand updateFeatureOptInServiceto implement it; exposegetFeatureOptInService()for consumersfeatureOptInrouter and integration tests to resolve services via DI instead ofnew/direct prismaFeaturesRepositorymodule in booking audit, bookings, and available slots containers; remove oldmodules/FeaturesbindingWritten by Cursor Bugbot for commit a7679a0. Configure here.