open-feature / spec

OpenFeature specification
https://openfeature.dev
Apache License 2.0
595 stars 35 forks source link

[bug] Multiple providers bound to one "name", and associated issues #192

Closed benjiro closed 1 year ago

benjiro commented 1 year ago

Spec: open-feature/spec@a4ffec3 See: https://github.com/open-feature/dotnet-sdk/issues/126

The spec allows a single instance of a provider to be bound to multiple names (even if it didn't allow this, any naive implementation would probably allow it to happen). We either need to prevent it or specify how it should work. We may want to specify that providers that are still bound to any client name are not shut down. - @toddbaert

I consider this a spec bug personally, because it constitutes a problematic ambiguity in the spec. - @toddbaert

cc @justinabrahms

Quote from @kinyoklion :+1:

Basic case.

var provider1 = new TestProvider();

openFeature.SetProvider("a",  provider1);

// Call init on provider1?

openFeature.SetProvider("a",  new TestProvider());

// Call shutdown on provider 1?

// Call init on new provider.

Two Names Scenario 1.

var provider = new TestProvider();

openFeature.SetProvider("a", provider);

// Call init on provider?

openFeature.SetProvider("b", provider);

// Provider already has init called. Do we call it again?

Two Names Scenario 2.

var provider1 = new TestProvider();

openFeature.SetProvider("a", provider1);
openFeature.SetProvider("b", provider1);

openFeature.SetProvider("b",  new TestProvider());

// We don't want to shutdown provider1, because it is still registered to "b".
benjiro commented 1 year ago

Let's continue the discussion about the following scenario described by @kinyoklion here https://github.com/open-feature/dotnet-sdk/pull/129#discussion_r1210810970

toddbaert commented 1 year ago

cc @lopitz @lukas-reining

toddbaert commented 1 year ago

@benjiro FYI I moved this from the dotnet-sdk repo.

lukas-reining commented 1 year ago

I totally agree. Also found that and implemented it in the JS SDK the way that this does not happen for the case between named and unnamed providers. But scenario 2 is not handled by the JS SDK now, I will fix that @toddbaert.

toddbaert commented 1 year ago

I totally agree. Also found that and implemented it in the JS SDK the way that this does not happen for the case between named and unnamed providers. But scenario 2 is not handled by the JS SDK now, I will fix that @toddbaert.

Let's wait for now to build some consensus, just so that you dont implement something that you have to change. Do you agree with the solution I've vaguely proposed?

Any alternatives?

lukas-reining commented 1 year ago

Yes I totally agree with that @toddbaert, this is fixing at least the shutdown for me. I already did that, was just 3 lines of code and a test. Will add the PR and we can merge it or change it once we have concencus what do you think?

toddbaert commented 1 year ago

Yes I totally agree with that @toddbaert, this is fixing at least the shutdown for me. I already did that, was just 3 lines of code and a test. Will add the PR and we can merge it or change it once we have concencus what do you think?

For now maybe add the PR here for reference.

lukas-reining commented 1 year ago

I fixed that in the JS SDK now. I had this check for the default provider already, but missed to do it for several named clients. https://github.com/open-feature/js-sdk/pull/444

toddbaert commented 1 year ago

Reading the spec a bit more, I think 1.1.2.2 and 1.1.2.3 technically addresses these concerns, though the non-normative helper-text could be improved.

justinabrahms commented 1 year ago

Thanks Todd. I agree with what's been stated:

basic:

2 names:

2 names 2:

toddbaert commented 1 year ago

I think this is taken care of with https://github.com/open-feature/spec/pull/193. Please re-open if you disagree, @benjiro