Skip to content

Conversation

@chrfwow
Copy link
Contributor

@chrfwow chrfwow commented Feb 10, 2026

This PR

Adds support for different providers with the same name in the multi provider. Since the interface Strategy has changed, this would be a breaking change if the multiprovider was not experimental.

The downside is, that the providers are not passed to the Strategy in a map, which makes the retrieval of a provider per name more difficult, and, depending on the number of providers, slower. However, since there will only ever be a handfull of providers, this should make no difference in real scenarios. Furthermore, the current map based version may result in unexpected behavior when two or more providers have the same name.

Related Issues

Fixes #1792

@chrfwow chrfwow requested review from a team as code owners February 10, 2026 14:58
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chrfwow, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the MultiProvider component to allow for the registration and management of multiple feature providers even if they share the same name. By transitioning from a map-based storage of providers to a list-based approach, the system can now accommodate scenarios where provider names are not unique. This change simplifies the internal architecture of the multi-provider, addressing potential issues with name collisions and enhancing flexibility, while acknowledging a minor trade-off in direct name-based provider retrieval within strategies.

Highlights

  • Provider Collection Type Change: The internal representation of feature providers within MultiProvider and its associated strategies has been changed from a Map<String, FeatureProvider> to a List<FeatureProvider>.
  • Support for Duplicate Provider Names: This modification enables the MultiProvider to handle multiple feature providers that may have the same name, resolving a previous limitation.
  • Simplified Provider Management: The buildProviders method, which previously managed name-based mapping and logged duplicate names, has been removed, streamlining the provider initialization process.
  • Metadata Structure Update: The MultiProviderMetadata now stores a List<Metadata> instead of a Map<String, Metadata> to reflect the change in how original provider metadata is tracked.
Changelog
  • src/main/java/dev/openfeature/sdk/multiprovider/FirstMatchStrategy.java
    • Updated the evaluate method signature to accept a List<FeatureProvider> instead of a Map<String, FeatureProvider>.
  • src/main/java/dev/openfeature/sdk/multiprovider/FirstSuccessfulStrategy.java
    • Modified the evaluate method signature to use a List<FeatureProvider> for providers.
  • src/main/java/dev/openfeature/sdk/multiprovider/MultiProvider.java
    • Refactored provider storage from Map to List.
    • Removed the buildProviders helper method.
    • Adjusted initialization and shutdown logic to iterate over the List of providers.
  • src/main/java/dev/openfeature/sdk/multiprovider/MultiProviderMetadata.java
    • Changed the originalMetadata field type from Map<String, Metadata> to List<Metadata>.
  • src/main/java/dev/openfeature/sdk/multiprovider/Strategy.java
    • Updated the evaluate method in the interface to pass a List<FeatureProvider> to strategies.
  • src/test/java/dev/openfeature/sdk/multiprovider/BaseStrategyTest.java
    • Adapted test setup to use List for orderedProviders instead of Map.
  • src/test/java/dev/openfeature/sdk/multiprovider/FirstSuccessfulStrategyTest.java
    • Adjusted test cases to add providers to a List rather than a Map.
  • src/test/java/dev/openfeature/sdk/multiprovider/MultiProviderTest.java
    • Updated tests to reflect the List-based storage of providers and their metadata, including changes to assertions and provider retrieval in custom strategies.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully refactors the MultiProvider to allow providers with identical names by switching from a Map to a List for storing providers. This is a well-documented breaking change for the experimental Strategy interface. The modifications are consistently applied throughout the affected classes and their corresponding tests. The test suite has been updated effectively to accommodate these changes. I've identified one minor area for improvement in a test case to enhance its robustness. Overall, the change is well-implemented.

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.51%. Comparing base (3857856) to head (c2cb2b9).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1848      +/-   ##
============================================
+ Coverage     92.51%   93.51%   +1.00%     
  Complexity      642      642              
============================================
  Files            58       58              
  Lines          1536     1527       -9     
  Branches        170      168       -2     
============================================
+ Hits           1421     1428       +7     
+ Misses           70       56      -14     
+ Partials         45       43       -2     
Flag Coverage Δ
unittests 93.51% <100.00%> (+1.00%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chrfwow chrfwow changed the title Allow for providers with equal name in the multiprovider feat: Allow for providers with equal name in the multiprovider Feb 11, 2026
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.

[Multi-provider] Reconsider type of "originalMetadata"

1 participant