Registry / devops / harness-featureflags

harness-featureflags

JSON →
library1.7.5pypypi✓ verified 83d ago

The `harness-featureflags` library provides the Python server SDK for Harness Feature Flags. It allows developers to integrate feature flag management into their Python applications, enabling dynamic control over features without redeploying code. The library is actively maintained, with frequent patch and minor releases, and is currently at version 1.7.5.

pip install harness-featureflags
INSTALL
IMPORT
SIG · HARNESS-FEATUREFLA
H
harness-featureflags
devopspythonv1.7.5
Install
3.0s avg
Import
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 26.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.0s · import 0.000s · 27MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CfClient
from featureflags.client import CfClient
from harness_featureflags.client import CfClient

This quickstart code demonstrates how to initialize the Harness Feature Flags Python SDK, define a target, and evaluate boolean and string feature flags. It continuously checks flag variations and prints their status until interrupted. Remember to replace `FF_API_KEY` with your actual Server SDK Key and update flag identifiers as needed. The SDK handles connection, caching, and updates automatically.

import os import time from harness_featureflags.client import CfClient from harness_featureflags.util import Target # Set your Harness Server SDK Key as an environment variable or replace directly API_KEY = os.environ.get('FF_API_KEY', 'YOUR_HAARNESS_SDK_KEY') # Set a target identifier for your user or application TARGET_IDENTIFIER = os.environ.get('FF_TARGET_IDENTIFIER', 'test-user-1') if not API_KEY or API_KEY == 'YOUR_HAARNESS_SDK_KEY': print("Error: FF_API_KEY not set. Please set the environment variable or replace the placeholder.") exit(1) def main(): client = CfClient(API_KEY) # Wait for the SDK to initialize client.wait_for_initialization() target = Target( identifier=TARGET_IDENTIFIER, name=TARGET_IDENTIFIER, attributes={ "email": f"{TARGET_IDENTIFIER}@example.com", "country": "US" } ) print(f"Client initialized. Target: {target.identifier}") try: while True: # Replace 'harnessappdemodarkmode' with your actual feature flag identifier is_dark_mode_enabled = client.bool_variation('harnessappdemodarkmode', target, False) print(f"Feature flag 'harnessappdemodarkmode' is {'enabled' if is_dark_mode_enabled else 'disabled'} for target {target.identifier}") string_flag_value = client.string_variation('another_string_flag', target, 'default_string') print(f"Feature flag 'another_string_flag' has value: {string_flag_value}") time.sleep(10) except KeyboardInterrupt: print("Stopping...") finally: client.close() print("SDK Closed.") if __name__ == '__main__': main()
Debug
Known issues
gotchaOlder versions of the SDK (prior to 1.6.4) had issues with rigidly pinned `tenacity` and `typing_extensions` dependencies, potentially causing conflicts with other libraries in your project. Ensure you are using version 1.6.4 or newer for improved dependency management.
fix
Upgrade to `harness-featureflags` version 1.6.4 or later using `pip install --upgrade harness-featureflags`.
affects: <1.6.4
gotchaSDK initialization failures are commonly caused by an invalid Server SDK Key or network connectivity issues to the Harness Feature Flags configuration service (https://config.ff.harness.io/api/1.0). Verify your key and network access.
fix
Double-check your `API_KEY` against the one provided in the Harness Platform. Ensure your application's environment has outbound network access to the Harness configuration URL. Listen for the `Event.FAILED` event during SDK initialization for more detailed error information.
affects: All versions
gotchaBy default, the SDK uses both streaming (for real-time updates) and polling (as a fallback). In case of connection issues, the SDK will gracefully degrade, either serving the most recently cached flag state or the default variation provided in the `variation` call if no cached value exists. Ensure your application logic accounts for these fallback scenarios to prevent unexpected behavior.
fix
Design your application with robust fallback logic using the default values in `variation` calls. For advanced control, you can configure streaming/polling behavior and HTTP client options (e.g., via `with_httpx_args` introduced in v1.7.0) to suit your environment's needs, such as disabling streaming for consistent session flags if updates are not required.
affects: All versions
Upgrade
Version history
1.7.5latest on PyPI · released Apr 9, 2026
Audit
Dependencies
requestsrequiredHTTP client for API communication.
tenacityrequiredProvides retry mechanisms for network operations.
typing-extensionsrequiredBackports and enhancements for Python's typing module.
cachetoolsrequiredUsed for caching feature flag configurations locally.
platformdirsrequiredHelps in determining appropriate platform-specific directories for caching.
jsonpath-ngrequiredUsed for JSON path parsing and querying.
Agent activity
6 hits · last 30 days
node
6
Resources
harness-featureflags — pip install harness-featureflags · libregistry