Skip to content

Conversation

@keelerm84
Copy link
Contributor

This PR

Introduces the following changes to the ProviderRegistry.

  1. Small validation improvement to ensure a domain is present when trying to specify a domain specific provider.
  2. There exists logic to prevent initializing and shutting down providers if they are registered multiple times. However, this logic doesn't account for a provider being registered as both a default, and a domain specific version. There are updates to address both of these situations.
  3. A small refactor to change the way provider status clean up is handled.
  4. Introduced unit tests to cover registry directly.

All of this functionality is in this single PR, but this can be split into individual PRs if desired. Each commit contains a singular bit of functionality or change, so reviewing individually might be easier.

Assuming we keep the PR as one, I have provided the changelog override necessary for release please.

BEGIN_COMMIT_OVERRIDE
refactor: Delete provider status instead of marking as NOT_READY
fix: Prevent providers from being shutdown multiple times
fix: Prevent providers from being initialized multiple times
fix: Validate domain is present when calling set_provider on registry
END_COMMIT_OVERRIDE

It is incorrect to call `ProviderRegister.set_provider` without a
provider AND a domain. A validation check exists for the provider, but
none for the domain.

In this commit, we introduce that domain validation and introduce tests
to capture this expected behavior.

Signed-off-by: Matthew Keeler <mkeeler@launchdarkly.com>
If a provider is set for two different domains, it will only be
initialized once. However, if a customer were to use a provider as both
default and domain specific, it would incorrectly be initialized twice.

Signed-off-by: Matthew Keeler <mkeeler@launchdarkly.com>
If a provider is set for two different domains, and then one of them is
replaced, it will only be shutdown once. However, if a customer were to
use a provider as both default and domain specific, replacing one or the
other would incorrectly shutdown both usages.

Signed-off-by: Matthew Keeler <mkeeler@launchdarkly.com>
Once a provider has been removed, there is no value in retaining a
reference to it in the `_provider_status` dictionary. Instead of
explicitly setting the status as `NOT_READY`, we can rely on this being
the default status served from the `get_provider_status` method,
allowing us to remove the dictionary entry entirely.

Signed-off-by: Matthew Keeler <mkeeler@launchdarkly.com>
@keelerm84 keelerm84 requested review from a team as code owners January 12, 2026 17:02
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 93.95973% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.74%. Comparing base (7c27c7a) to head (f7998e6).

Files with missing lines Patch % Lines
tests/provider/test_registry.py 93.61% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #560      +/-   ##
==========================================
- Coverage   97.83%   97.74%   -0.10%     
==========================================
  Files          40       41       +1     
  Lines        1849     1993     +144     
==========================================
+ Hits         1809     1948     +139     
- Misses         40       45       +5     
Flag Coverage Δ
unittests 97.74% <93.95%> (-0.10%) ⬇️

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.

Copy link
Member

@gruebel gruebel left a comment

Choose a reason for hiding this comment

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

overall looks good, but as stated I'm not sure about the shutdown change

Comment on lines +34 to +35
old_provider not in providers.values()
and old_provider != self._default_provider
Copy link
Member

Choose a reason for hiding this comment

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

can you switch the statements, it is faster to check the second one, so if this is false there is not need to check all the providers.

):
self._shutdown_provider(old_provider)
if provider not in providers.values():
if provider not in providers.values() and provider != self._default_provider:
Copy link
Member

Choose a reason for hiding this comment

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

saem here

if hasattr(provider, "shutdown"):
provider.shutdown()
self._provider_status[provider] = ProviderStatus.NOT_READY
del self._provider_status[provider]
Copy link
Member

Choose a reason for hiding this comment

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

not sure about this change, https://openfeature.dev/specification/sections/providers#requirement-252 states

After a provider's shutdown function has terminated, the provider SHOULD revert to its uninitialized state.

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.

2 participants