Skip to content

fix: detach replaced and shut-down providers - #341

Merged
josecolella merged 7 commits into
mainfrom
fix/detach-replaced-providers
Oct 22, 2026
Merged

josecolella merged 7 commits into
mainfrom
fix/detach-replaced-providers

Conversation

@josecolella

@josecolella josecolella commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • When a provider loses its last domain binding or is shut down, the SDK now detaches it.
  • Events from providers that are no longer registered are dropped (spec 1.1.2.3, 1.6.2, 2.5.2).
  • Part of Spec v0.9.0 compliance #300.

Context for reviewers

  • Before, a replaced provider stayed attached. Its events still reached API handlers and re-added it to the status registry.
  • A slow async init that finished after its provider was replaced or shut down did the same.
  • This is the first of a small stack of changes in configuration.rb. The next PR, on event delivery order (Reentrant provider events reach client callbacks out of order #332), builds on the new provider_bound? check.

Behavior changes worth noting

  • Events a provider emits from inside its own shutdown are now dropped. Its status is already NOT_READY at that point (1.7.6).
  • While shutdown runs, providers are already unbound. provider(domain:) and provider_metadata return nil, and every event is dropped, including a late async init's READY.

How to review

  • The substance is in configuration.rb.
  • The configuration_spec.rb change registers the provider first, because the old test dispatched an event for a provider that was never registered.

🤖 Generated with Claude Code

josecolella and others added 5 commits October 22, 2026 14:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jose Colella <jose.colella@gusto.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jose Colella <jose.colella@gusto.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jose Colella <jose.colella@gusto.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jose Colella <jose.colella@gusto.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jose Colella <jose.colella@gusto.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3523964c-be41-46fa-92ec-f99b214aed85
📥 Commits

Reviewing files that changed from the base of the PR and between 2b93aa4 and 8501a47.

📒 Files selected for processing: 5
  • lib/open_feature/sdk/configuration.rb
  • sig/open_feature/sdk/configuration.rbs
  • spec/open_feature/sdk/configuration_spec.rb
  • spec/specification/flag_evaluation_api_spec.rb
  • spec/specification/provider_spec.rb
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.52%. Comparing base (2b93aa4) to head (8501a47).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #341   +/-   ##
=======================================
  Coverage   99.51%   99.52%           
=======================================
  Files          32       32           
  Lines         832      841    +9     
=======================================
+ Hits          828      837    +9     
  Misses          4        4           

☔ View full report in Codecov by Harness.
📢 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.

@josecolella
josecolella marked this pull request as ready for review October 22, 2026 22:59
@josecolella
josecolella requested a review from a team as a code owner October 22, 2026 22:59
Copilot AI balanced review requested due to automatic review settings October 22, 2026 22:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Lifecycle races still allow initialization events during shutdown and registry entries to be recreated after provider replacement.

2 open issues
What changed in this PR

This PR improves provider lifecycle cleanup in the Ruby SDK by detaching replaced and shut-down providers and filtering events from unregistered providers, advancing the compliance work tracked in #300.

Changes:

  • Detach providers after their last domain binding is removed and before shutdown.
  • Add a binding check to reject late provider events.
  • Add lifecycle regression tests and update the corresponding type signature.
File Description
spec/​specification/​provider_spec.rb Verify reinitialization when a replaced provider is registered again.
spec/​specification/​flag_evaluation_api_spec.rb Cover detachment, shared bindings, and late async initialization.
spec/​open_feature/​sdk/​configuration_spec.rb Register the provider before testing event-handler error logging.
sig/​open_feature/​sdk/​configuration.rbs Declare the new binding-check helper.
lib/​open_feature/​sdk/​configuration.rb Detach inactive providers and guard event dispatch by binding status.

Review effort: Balanced

Comment thread lib/open_feature/sdk/configuration.rb Resolved
Comment thread lib/open_feature/sdk/configuration.rb Resolved
josecolella and others added 2 commits October 22, 2026 16:22
…roviders

Signed-off-by: Jose Colella <jose.colella@gusto.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shutdown now unbinds providers before calling their shutdown, so a READY
from an async init that finishes mid-shutdown no longer flips the state
back from NOT_READY or reaches handlers.

The binding check and state update in dispatch_provider_event now run
under the provider mutex, so an event that passed the check cannot
re-track a provider that was replaced in between.

Signed-off-by: Jose Colella <jose.colella@gusto.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@josecolella
josecolella merged commit 50ddc8f into main Oct 22, 2026
30 of 32 checks passed
@josecolella
josecolella deleted the fix/detach-replaced-providers branch October 22, 2026 23:31
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