Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot make FeatureManagement provider work with On/Off features declaration #263

Open
kaluznyt opened this issue Aug 22, 2024 · 4 comments
Assignees

Comments

@kaluznyt
Copy link

Hi,

I'm encountering an issue with having the OpenFeature / FeatureManagement provider to work with the On/Off features declaration:
https://learn.microsoft.com/en-us/azure/azure-app-configuration/feature-management-dotnet-reference?pivots=stable-version#onoff-declaration

featureFlags.json

{
    // Define feature flags in config file
    "FeatureManagement": {
        "FeatureT": true, // On feature
    }
}

Having this code:

var configurationBuilder2 = new ConfigurationBuilder();
configurationBuilder2.AddJsonFile("featureFlags.json");
IConfiguration featureFlagsConfig = configurationBuilder2.Build();

var featureManagementProvider = new FeatureManagementProvider(featureFlagsConfig);
await OpenFeature.Api.Instance.SetProviderAsync(featureManagementProvider);
var client = OpenFeature.Api.Instance.GetClient();

var feature = await client.GetBooleanValue("FeatureT", false);

It always evaluates fo false.

But when provided with this code:

{
  "FeatureManagement": {
    "FeatureT": {
      "Allocation": {
        "DefaultWhenEnabled": "FlagEnabled",
        "DefaultWhenDisabled": "FlagDisabled"
      },
      "Variants": [
        {
          "Name": "FlagEnabled",
          "ConfigurationValue": true
        },
        {
          "Name": "FlagDisabled",
          "ConfigurationValue": false
        }
      ],
      "EnabledFor": [
        {
          "Name": "AlwaysOn"
        }
      ]
    }
  }
}

It works fine.

Basically, we have a lot of boolean flags, which doesn't make sense to introduce that kind of structure per each.

But perhaps I'm missing something.

This if just a first step to migrate from FeatureManagement to OpenFeature, before connecting with third party provider.

Any hints ?

@toddbaert toddbaert changed the title Cannot make this work with On/Off features declaration Cannot make FeatureManagement provider work with On/Off features declaration Aug 22, 2024
@toddbaert
Copy link
Member

@ericpattison is support for this simple configuration perhaps a missing feature?

@kaluznyt
Copy link
Author

Guessing the issue might be with handling anything other than boolean, however, I workaround it by implementing a custom FeatureManager that injects IFeatureManager and implements just GetBoolean method, since it's the only feature we need for now.

@ericpattison
Copy link
Contributor

It likely has to do with the fact that FeatureManagement was originally only designed to support Boolean checks.
The reason this implementation works is due to a still not fully released feature for what they call "Variants".
I'm thinking it should be a simple adjustment to allow for the simpler flags, but it would only work for boolean values since that's the only thing you can do without variants.

@kaluznyt
Copy link
Author

Sure, thanks, it was just my thoughts as well while creating a custom provider for it.

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

No branches or pull requests

3 participants