Repository navigation
Commit 330768c
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
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | 139 | | |
152 | 140 | | |
153 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
| |||
0 commit comments