Skip to content

Commit 330768c

Browse files
committed
fix(unleash): drop the track override so client.track no-ops
openfeature-sdk 0.9.0 added tracking, and `OpenFeatureClient.track` calls `provider.track(tracking_event_name, merged_eval_context, tracking_event_details)` -- three positional arguments. The provider's own no-op declared `track(event_name, event_details=None)`, which takes two, so the call raises TypeError: UnleashProvider.track() takes from 2 to 3 positional arguments but 4 were given instead of doing nothing. Requirement 6.1.1 says the client's track MUST be a no-op when the provider does not implement tracking, so the method that exists to satisfy it was the thing breaking it. This is reachable from a released install, not just from this branch: the package declares `openfeature-sdk>=0.8.2`, so a fresh resolve takes 0.10.0 and any `client.track(...)` call raises. It went unnoticed because the workspace lock held 0.8.4, where the SDK has no tracking API at all and therefore never calls this method. `AbstractProvider.track` is already a no-op with the signature the client calls, so deleting the override is the whole fix. Widening the signature instead would mean importing `TrackingEventDetails` for the annotation, and `openfeature.track` does not exist before 0.9.0 -- with the floor at 0.8.2 that turns a broken `client.track` into a ModuleNotFoundError on import, which is worse. Raising the floor to 0.9.0 would also work, but the provider needs nothing from that release beyond a type it only uses to say it does nothing. Verified against both ends of the declared range: on 0.10.0, registering the provider and calling `client.track("my-event")` raised TypeError before and returns None after; on 0.8.4, importing the provider raises ModuleNotFoundError with the annotation and imports cleanly without it. mypy caught the narrow signature as two `[override]` errors against both `AbstractProvider` and `FeatureProvider`; it was the only type error the 0.10.0 move produced anywhere in the workspace. The existing `hasattr(provider, "track")` assertion could not catch it -- it holds either way -- so the test now calls track the way the SDK does, which is also what guards against the override coming back. Fixes #433 Signed-off-by: Simon Schrottner <simon.schrottner@flagsmith.com>
1 parent 283bfe8 commit 330768c

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

‎providers/openfeature-provider-unleash/src/openfeature/contrib/provider/unleash/__init__.py‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,6 @@ def _unleash_event_callback(self, event: BaseEvent) -> None:
136136
self._status = ProviderStatus.READY
137137
self._event_manager.handle_unleash_event(event)
138138

139-
def track(
140-
self,
141-
event_name: str,
142-
event_details: dict | None = None,
143-
) -> None:
144-
"""No-op tracking method.
145-
146-
Tracking is not implemented for this provider. Per the OpenFeature spec,
147-
when the provider doesn't support tracking, client.track calls should no-op.
148-
"""
149-
return None
150-
151139
def _build_unleash_context(
152140
self, evaluation_context: EvaluationContext | None = None
153141
) -> dict[str, Any] | None:

‎providers/openfeature-provider-unleash/tests/test_provider.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ def test_unleash_provider_all_methods_implemented():
119119
assert hasattr(provider, "add_handler")
120120
assert hasattr(provider, "remove_handler")
121121
assert hasattr(provider, "track")
122+
# Tracking is not implemented, so track is inherited from
123+
# AbstractProvider and no-ops. Called the way OpenFeatureClient.track
124+
# calls it -- positionally -- since a narrower override raises
125+
# TypeError there.
126+
assert provider.track("some-event", EvaluationContext(), None) is None
122127

123128
provider.shutdown()
124129

0 commit comments

Comments
 (0)