Skip to content

fix: enable DI for FeatureOptInService#13

Open
tomerqodo wants to merge 2 commits into
cursor_full_base_fix_enable_di_for_featureoptinservice_pr13from
cursor_full_head_fix_enable_di_for_featureoptinservice_pr13
Open

fix: enable DI for FeatureOptInService#13
tomerqodo wants to merge 2 commits into
cursor_full_base_fix_enable_di_for_featureoptinservice_pr13from
cursor_full_head_fix_enable_di_for_featureoptinservice_pr13

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 25, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#13


Note

Introduces DI wiring for feature opt-in and flags, replacing direct instantiation with container-resolved services.

  • Add DI modules/containers for FeatureOptInService and FeaturesRepository (modules/FeatureOptInService, modules/FeaturesRepository, containers/FeatureOptInService, containers/FeaturesRepository), plus new token sets FLAGS_DI_TOKENS and FEATURE_OPT_IN_DI_TOKENS merged into DI_TOKENS
  • Define IFeatureOptInService and update FeatureOptInService to implement it; expose getFeatureOptInService() for consumers
  • Update TRPC featureOptIn router and integration tests to resolve services via DI instead of new/direct prisma
  • Replace imports to use FeaturesRepository module in booking audit, bookings, and available slots containers; remove old modules/Features binding

Written by Cursor Bugbot for commit a7679a0. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

const featuresRepository = new FeaturesRepository(prisma);
const service = new FeatureOptInService(featuresRepository);
const featuresRepository = getFeaturesRepository();
const service = getFeatureOptInService();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant