Skip to content

Commit f0394cd

Browse files
Copilotaepfli
andcommitted
Document selector migration guidance for in-process mode
- Add comprehensive migration guidance section for selector handling - Clarify that selector changes only affect in-process and file modes - Document backward compatibility and future breaking changes - Update provider docstring with selector migration note - Link to upstream flagd issue #1814 Co-authored-by: aepfli <[email protected]>
1 parent 94a8942 commit f0394cd

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

providers/openfeature-provider-flagd/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ The default options can be defined in the FlagdProvider constructor.
9393
| retry_backoff_ms | FLAGD_RETRY_BACKOFF_MS | int | 1000 | rpc |
9494
| offline_flag_source_path | FLAGD_OFFLINE_FLAG_SOURCE_PATH | str | null | in-process |
9595

96+
> [!NOTE]
97+
> The `selector` configuration is only used in **in-process** mode for filtering flag configurations. See [Selector Handling](#selector-handling-in-process-mode-only) for migration guidance.
98+
9699
<!-- not implemented
97100
| target_uri | FLAGD_TARGET_URI | alternative to host/port, supporting custom name resolution | string | null | rpc & in-process |
98101
| socket_path | FLAGD_SOCKET_PATH | alternative to host port, unix socket | String | null | rpc & in-process |
@@ -103,6 +106,47 @@ The default options can be defined in the FlagdProvider constructor.
103106
> [!NOTE]
104107
> Some configurations are only applicable for RPC resolver.
105108
109+
### Selector Handling (In-Process Mode Only)
110+
111+
> [!IMPORTANT]
112+
> This section only applies to **in-process** and **file** resolver modes. RPC mode is not affected by selector handling changes.
113+
114+
#### Migration Guidance
115+
116+
As of flagd v0.11.0 and related services, selector normalization has been updated to prefer gRPC metadata headers over request body fields for the `selector` parameter. This change affects how the in-process provider communicates with flagd's sync service.
117+
118+
**Current Behavior (Preferred):**
119+
The Python SDK currently passes the `selector` via the gRPC request body when using in-process mode. While this approach continues to work for backward compatibility, the flagd ecosystem is transitioning to header-based selector passing.
120+
121+
**Configuration Example:**
122+
```python
123+
from openfeature import api
124+
from openfeature.contrib.provider.flagd import FlagdProvider
125+
from openfeature.contrib.provider.flagd.config import ResolverType
126+
127+
api.set_provider(FlagdProvider(
128+
resolver_type=ResolverType.IN_PROCESS,
129+
selector="my-flag-source", # Currently passed in request body
130+
))
131+
```
132+
133+
#### Backward Compatibility
134+
135+
The current implementation maintains backward compatibility by continuing to pass selectors in the request body. flagd services support both approaches:
136+
- **Request body selector** (current implementation) - Supported for backward compatibility
137+
- **Header-based selector** (future preferred) - Will be supported in a future SDK update
138+
139+
#### Future Breaking Change
140+
141+
In a future major version of this SDK, the selector handling will be updated to use gRPC metadata headers (`flagd-selector`) instead of the request body field. This aligns with the flagd ecosystem's standardized approach to selector normalization.
142+
143+
**Action Required:**
144+
No immediate action is required. The current implementation will continue to work with both current and future versions of flagd services. Monitor release notes for announcements about the transition to header-based selectors.
145+
146+
**Related Resources:**
147+
- Upstream issue: [open-feature/flagd#1814](https://github.com/open-feature/flagd/issues/1814)
148+
- Selector normalization affects in-process evaluations that filter flag configurations by source
149+
106150
<!--
107151
### Unix socket support
108152
Unix socket communication with flagd is facilitated by usaging of the linux-native `epoll` library on `linux-x86_64`

providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/provider.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def __init__( # noqa: PLR0913
7575
:param deadline_ms: the maximum to wait before a request times out
7676
:param timeout: the maximum time to wait before a request times out
7777
:param retry_backoff_ms: the number of milliseconds to backoff
78+
:param selector: filter flag configurations by source (in-process mode only)
79+
Note: Currently passed via request body. Future versions will use
80+
gRPC metadata headers. See README for migration guidance.
7881
:param offline_flag_source_path: the path to the flag source file
7982
:param stream_deadline_ms: the maximum time to wait before a request times out
8083
:param keep_alive_time: the number of milliseconds to keep alive

0 commit comments

Comments
 (0)