OpenFeature Provider for flagd

raw JSON →
0.4.1 verified Fri May 01 auth: no python

This package provides an OpenFeature provider for the flagd flag evaluation engine. It connects to a flagd instance via gRPC, supporting in-process and remote evaluation. Current version: 0.4.1. Requires Python >=3.10. Active development with frequent releases.

pip install openfeature-provider-flagd
error ModuleNotFoundError: No module named 'openfeature'
cause Missing openfeature-sdk dependency.
fix
pip install openfeature-sdk openfeature-provider-flagd
error grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.UNAVAILABLE...
cause Cannot connect to flagd instance at the specified host and port.
fix
Verify flagd is running and accessible. Check FLAGD_HOST environment variable or pass correct host/port to FlagdProvider.
error AttributeError: module 'openfeature' has no attribute 'provider'
cause Using an older version of openfeature-sdk that does not have the 'provider' submodule.
fix
Upgrade openfeature-sdk: pip install --upgrade openfeature-sdk
error TypeError: FlagdProvider.__init__() got an unexpected keyword argument 'host'
cause Using an old version of openfeature-provider-flagd (pre-0.3.0) that used different constructor arguments.
fix
Upgrade to latest version: pip install --upgrade openfeature-provider-flagd
breaking Python 3.9 support dropped in v0.4.0. Upgrade to Python >=3.10.
fix Ensure your runtime uses Python 3.10 or later.
breaking Fractional bucketing behaviour changed in v0.4.0. Existing targetting rules may produce different results.
fix Review fractional bucketing configuration and test your flag rules after upgrade.
breaking Graceful fallback to code default changed in v0.3.0: when no default variant is configured, the provider now returns the code default instead of raising an error.
fix If you rely on exceptions for missing defaults, adjust your error handling.
deprecated The old import path 'from flagd import FlagdProvider' is deprecated.
fix Use 'from openfeature.provider.flagd import FlagdProvider'.
gotcha gRPC connection failure may not raise immediately; default timeout may cause delayed errors.
fix Configure timeout via FlagdProvider(host=..., port=..., timeout=5) to fail fast.

Set up the flagd provider and evaluate a boolean flag.

import os
from openfeature import api
from openfeature.provider.flagd import FlagdProvider

# Initialize the provider with a flagd host (default localhost:8013)
provider = FlagdProvider(host=os.environ.get('FLAGD_HOST', 'localhost'), port=8013)
api.set_provider(provider)
client = api.get_client()

# Evaluate a boolean flag
flag_value = client.get_boolean_value("my-flag", False)
print(f"Flag value: {flag_value}")