Skip to content

Improve dependency injection consistency across initialization paths #8368

Description

@Shaddoll

Problem

The codebase has inconsistent patterns for dependency management during initialization. Some components recreate objects from lower-level dependencies (like Clients) when higher-level objects (like Collections/wrappers) are already available or could be injected.

Pattern Observed

When using fx-based dependency injection, certain modules provide fully-configured objects. However, downstream initialization code sometimes ignores these and recreates equivalent objects from the underlying primitives with identical parameters.

This creates a pattern where:

  • Module A provides Object X via dependency injection
  • Component B receives the primitive that X wraps
  • Component B recreates an equivalent X from the primitive
  • Result: Two instances of X with identical configuration

Impact

  • Consistency: Mixing dependency injection with manual object creation
  • Maintainability: Duplicate initialization logic scattered across codebase
  • Single source of truth: Multiple instances created from same configuration
  • Code clarity: Unclear whether injected objects should be used or recreated

Suggestion

Review initialization paths to:

  1. Identify where fx-injected objects could be reused instead of recreated
  2. Thread injected dependencies through initialization chains consistently
  3. Document patterns for when to inject vs. recreate dependencies
  4. Ensure fx-based and non-fx paths have clear, consistent patterns

This is a code health and design consistency issue that affects maintainability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-infoDEPRECATED -> use triage/needs-infotriage/needs-infoBlocked pending more info from the reporter (repro, version, logs) before triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions