Skip to content

Adding the same custom strategy multiple times on a feature flag does not evaluate all instances (last one wins) #369

Description

@kanishka-shashan

Describe the bug

When adding the same custom strategy implementation multiple times to a single feature flag (with different parameters), only one of the strategy instances appears to be evaluated effectively.

The observed behavior is that the last-added instance determines the final evaluation result, while earlier instances are ignored.

Note

Only if we upgrade unleash-client-java from 11.1.1 to 11.2.1.

Steps to reproduce the bug

  1. Implement a custom strategy in Java.
  2. Add the same custom strategy to a feature flag multiple times.
  3. Configure different parameters for each instance.
  4. Evaluate the flag with a context that should match one of the earlier instances.
  5. Observe that only the last-added strategy instance is effectively applied.

Reordering the strategies changes the outcome.

Expected behavior

Unleash documentation states that:

If a feature flag has multiple activation strategies, the flag is enabled if any strategy evaluates to true.

Therefore, when the same custom strategy is added multiple times to a feature flag:

  • Each strategy instance should be evaluated independently.
  • Each instance should receive its own parameters.
  • The flag should be enabled if any of the strategy instances evaluate to true.

Logs, error output, etc.

Screenshots

No response

Additional context

Technical Context

There is a related commit in yggdrasil-bindings that introduces indexed internal strategy identifiers:

[https://github.com/Unleash/yggdrasil-bindings/commit/f8794cfd072644c500385fbaa769ccca8b702e78](Unleash/yggdrasil-bindings@f8794cf

This appears to address potential result key collisions.

However, stacking the same custom strategy multiple times still results in only one instance being respected during evaluation.

Questions

  • Is stacking the same custom strategy multiple times on a single feature flag officially supported?
  • If supported, should each instance be evaluated independently?
  • If not supported, should this limitation be documented?

Environment

Unleash Server version: Tested on 5.6.9, 6.10.1, 7.4.1
unleash-client-java version: 11.2.1
yggdrasil-engine version: 0.4.4
Java version: 25
Deployment: Docker

Unleash version

6.10.1

Subscription type

Open source

Hosting type

Self-hosted

SDK information (language and version)

unleash-client-java 11.2.0 onwards

Metadata

Metadata

Labels

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions