Skip to main content

Featureflip OpenFeature Provider (Python)

OpenFeature provider for Featureflip, backed by the Featureflip Python server SDK. Use the vendor-neutral OpenFeature API while Featureflip serves your flags.

Installation

pip install featureflip-openfeature-provider

featureflip and openfeature-sdk are declared as lower-bounded dependencies rather than pinned — your application controls their versions, and a single featureflip copy is what lets this provider and any direct SDK usage share one underlying client core.

Quickstart

from openfeature import api
from featureflip_openfeature import FeatureflipProvider

api.set_provider_and_wait(FeatureflipProvider(sdk_key="your-server-sdk-key"))

client = api.get_client()

enabled = client.get_boolean_value(
    "new-checkout",
    False,
    EvaluationContext(targeting_key="user-42", attributes={"plan": "pro"}),
)

The provider owns the client it creates and closes it on shutdown. To share one client with code that uses the SDK directly, construct the client yourself and pass it in — the provider will not close a client it did not create:

from featureflip import FeatureflipClient

client = FeatureflipClient(sdk_key="your-server-sdk-key")
api.set_provider_and_wait(FeatureflipProvider(client=client))

Note that FeatureflipClient(...) blocks on the initial flag fetch. With the sdk_key form the provider defers that to initialize(), so the wait happens inside OpenFeature's provider setup rather than in your constructor.

Use set_provider_and_wait, not set_provider. The plain form runs the provider's initialize() on a background thread and returns immediately, so flags may not have loaded yet and the evaluations right after it can return your defaults. set_provider_and_wait blocks until initialization finishes.

Context mapping

OpenFeature context Featureflip context
targeting_key user_id (used for rollout bucketing)
Any other attribute Passed through unchanged

An explicit user_id (or its alias userId) attribute takes precedence over targeting_key. Without either, percentage rollouts bucketed by user skip that caller, who gets the next matching rule or the default variation. The SDK logs a warning once per flag and rule.

Evaluation reasons

Featureflip reason OpenFeature reason
RULE_MATCH TARGETING_MATCH
FALLTHROUGH DEFAULT
FLAG_DISABLED DISABLED
PREREQUISITE_FAILED PREREQUISITE_FAILED (custom)
FLAG_NOT_FOUND ERROR + FLAG_NOT_FOUND
ERROR ERROR + GENERAL

No standard OpenFeature reason models an unmet prerequisite. Reasons are open strings, so the provider surfaces PREREQUISITE_FAILED verbatim rather than mislabelling it.

On an error reason the provider returns your default value, not the flag's off-variation — that value can be wrong-typed, and the caller's default is what the OpenFeature error contract prescribes.

Flag metadata

Successful resolutions carry ruleId and prerequisiteKey in flag_metadata when the evaluation produced them.

Type handling

Featureflip does not type-check flag values against the accessor you call, so the provider enforces OpenFeature's TYPE_MISMATCH contract itself. A mismatched read returns your default with reason ERROR and error code TYPE_MISMATCH.

Accessor Accepts
get_boolean_value booleans only
get_string_value strings only
get_integer_value integers, and whole-number floats (1.0, 1e2)
get_float_value any JSON number, including integers
get_object_value objects and arrays only — not strings

Booleans are deliberately rejected by the numeric accessors. bool is a subclass of int in Python, so without an explicit exclusion a boolean flag would satisfy get_integer_value and hand you 1.

Events

The provider emits OpenFeature's PROVIDER_CONFIGURATION_CHANGED whenever Featureflip flag configuration changes, with flags_changed naming the affected keys:

from openfeature.event import ProviderEvent

client.add_handler(
    ProviderEvent.PROVIDER_CONFIGURATION_CHANGED,
    lambda details: print("changed:", details.flags_changed),
)

The initial flag load does not raise this event — OpenFeature signals that with PROVIDER_READY. Beyond flags whose own configuration changed, the event also names flags whose evaluated value moves as a result: those referencing an edited segment, and those depending on a changed flag through a prerequisite.

Requires featureflip >= 2.7.0, which added the underlying update hook.

Tracking

client.track(...) forwards to the Featureflip SDK's custom event tracking. TrackingEventDetails.attributes become the event metadata, and a numeric value is included under the value key.

Featureflip counts each event name, per environment. The metadata is transmitted with the event but is not stored, and event counts are not surfaced in the app or API.

License

Apache-2.0

Metadata

Release files for featureflip-openfeature-provider 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for featureflip-openfeature-provider 0.2.1
File Size Uploaded Provenance Actions
featureflip_openfeature_provider-0.2.1.tar.gz 21.6 kB Without provenance Details for featureflip_openfeature_provider-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for featureflip-openfeature-provider 0.2.1
File Interpreter ABI Platform Actions
featureflip_openfeature_provider-0.2.1-py3-none-any.whl Python 3 none any Details for featureflip_openfeature_provider-0.2.1-py3-none-any.whl

Total release size: 36.2 kB

Release files / featureflip_openfeature_provider-0.2.1.tar.gz

Download URL featureflip_openfeature_provider-0.2.1.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a011de0e290e71f0da90ad600dfb4e1c186b7e701f3a278eb2b88bd494938173
BLAKE2b-256 checksum
How to use checksums
bff5c4e0b58720a8aef25860f40b7bb7c7ddf07125b95595b3ce60c99725c898
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / featureflip_openfeature_provider-0.2.1-py3-none-any.whl

Download URL featureflip_openfeature_provider-0.2.1-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbb539cc6fd1122e643c8fb39bc3d5d76cc8fa3f267103117f7b1d5e16e45f9d
BLAKE2b-256 checksum
How to use checksums
badd7f920603a9a42995e81e4cc6459b33a378239957b4c070e1061596adfab6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for featureflip-openfeature-provider 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page