Skip to content

Commit 3584739

Browse files
feat: warn that payload filtering has no effect with FDv2
Co-Authored-By: Bee Klimt <bklimt@launchdarkly.com>
1 parent 5da1515 commit 3584739

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎ldclient/async_config.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def __init__(
208208
:param plugins: A list of plugins to be used with the SDK. Plugin support is currently experimental and subject to change.
209209
:param enable_event_compression: Whether or not to enable GZIP compression for outgoing events.
210210
:param omit_anonymous_contexts: Sets whether anonymous contexts should be omitted from index and identify events.
211-
:param payload_filter_key: The payload filter is used to selectively limited the flags and segments delivered in the data source payload.
211+
:param payload_filter_key: The payload filter is used to selectively limited the flags and segments delivered in the data source payload. Payload filtering is not supported with the FDv2 data system, so this has no effect on FDv2 requests.
212212
:param datasystem_config: Configuration for the upcoming enhanced data system design. This is experimental and should not be set without direction from LaunchDarkly support.
213213
"""
214214
self.__sdk_key = validate_sdk_key_format(sdk_key, log)
@@ -439,6 +439,9 @@ def payload_filter_key(self) -> Optional[str]:
439439
polling data sources. It will not affect TestData or FileData data
440440
sources, nor will it be applied to any data source provided through the
441441
{#data_source} config property.
442+
443+
Payload filtering is not supported with the FDv2 data system, so this
444+
key has no effect on requests made by FDv2 data sources.
442445
"""
443446
return self.__payload_filter_key
444447

‎ldclient/config.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def __init__(
390390
:param plugins: A list of plugins to be used with the SDK. Plugin support is currently experimental and subject to change.
391391
:param enable_event_compression: Whether or not to enable GZIP compression for outgoing events.
392392
:param omit_anonymous_contexts: Sets whether anonymous contexts should be omitted from index and identify events.
393-
:param payload_filter_key: The payload filter is used to selectively limited the flags and segments delivered in the data source payload.
393+
:param payload_filter_key: The payload filter is used to selectively limited the flags and segments delivered in the data source payload. Payload filtering is not supported with the FDv2 data system, so this has no effect on FDv2 requests.
394394
:param datasystem_config: Configuration for the upcoming enhanced data system design. This is experimental and should not be set without direction from LaunchDarkly support.
395395
"""
396396
self.__sdk_key = validate_sdk_key_format(sdk_key, log)
@@ -661,6 +661,9 @@ def payload_filter_key(self) -> Optional[str]:
661661
polling data sources. It will not affect TestData or FileData data
662662
sources, nor will it be applied to any data source provided through the
663663
{#data_source} config property.
664+
665+
Payload filtering is not supported with the FDv2 data system, so this
666+
key has no effect on requests made by FDv2 data sources.
664667
"""
665668
return self.__payload_filter_key
666669

‎ldclient/impl/datasystem/fdv2.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def __init__(
6060
"""
6161
self._config = config
6262
self._data_system_config = data_system_config
63+
64+
if config.payload_filter_key is not None:
65+
log.warning("Payload filtering is not supported with the FDv2 data system; the configured payload filter has no effect on FDv2 requests")
66+
6367
self._synchronizers: List[DataSourceBuilder[Synchronizer]] = list(data_system_config.synchronizers) if data_system_config.synchronizers else []
6468
self._fdv1_fallback_synchronizer_builder = data_system_config.fdv1_fallback_synchronizer
6569
self._disabled = self._config.offline

‎ldclient/testing/impl/datasystem/test_fdv2_datasystem.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint: disable=missing-docstring
22

3+
import logging
34
import os
45
import tempfile
56
from threading import Event
@@ -846,3 +847,17 @@ def test_environment_id_is_not_recorded_from_non_valid_updates():
846847

847848
assert fdv2.environment_id == "env-from-sync"
848849
fdv2.stop()
850+
851+
852+
def test_warns_when_payload_filter_key_is_configured(caplog):
853+
caplog.set_level(logging.WARNING, logger="ldclient.util")
854+
FDv2(Config(sdk_key="dummy", payload_filter_key="microservice-1"), DataSystemConfig(initializers=None, synchronizers=None))
855+
856+
assert any("Payload filtering is not supported with the FDv2 data system" in record.message for record in caplog.records)
857+
858+
859+
def test_does_not_warn_when_payload_filter_key_is_not_configured(caplog):
860+
caplog.set_level(logging.WARNING, logger="ldclient.util")
861+
FDv2(Config(sdk_key="dummy"), DataSystemConfig(initializers=None, synchronizers=None))
862+
863+
assert not any("Payload filtering" in record.message for record in caplog.records)

0 commit comments

Comments
 (0)