Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ldclient/async_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def __init__(
:param plugins: A list of plugins to be used with the SDK. Plugin support is currently experimental and subject to change.
:param enable_event_compression: Whether or not to enable GZIP compression for outgoing events.
:param omit_anonymous_contexts: Sets whether anonymous contexts should be omitted from index and identify events.
:param payload_filter_key: The payload filter is used to selectively limited the flags and segments delivered in the data source payload.
: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.
:param datasystem_config: Configuration for the upcoming enhanced data system design. This is experimental and should not be set without direction from LaunchDarkly support.
"""
self.__sdk_key = validate_sdk_key_format(sdk_key, log)
Expand Down Expand Up @@ -476,6 +476,9 @@ def payload_filter_key(self) -> Optional[str]:
polling data sources. It will not affect TestData or FileData data
sources, nor will it be applied to any data source provided through the
{#data_source} config property.

Payload filtering is not supported with the FDv2 data system, so this
key has no effect on requests made by FDv2 data sources.
"""
return self.__payload_filter_key

Expand Down
5 changes: 4 additions & 1 deletion ldclient/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def __init__(
:param plugins: A list of plugins to be used with the SDK. Plugin support is currently experimental and subject to change.
:param enable_event_compression: Whether or not to enable GZIP compression for outgoing events.
:param omit_anonymous_contexts: Sets whether anonymous contexts should be omitted from index and identify events.
:param payload_filter_key: The payload filter is used to selectively limited the flags and segments delivered in the data source payload.
: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.
:param datasystem_config: Configuration for the upcoming enhanced data system design. This is experimental and should not be set without direction from LaunchDarkly support.
"""
self.__sdk_key = validate_sdk_key_format(sdk_key, log)
Expand Down Expand Up @@ -681,6 +681,9 @@ def payload_filter_key(self) -> Optional[str]:
polling data sources. It will not affect TestData or FileData data
sources, nor will it be applied to any data source provided through the
{#data_source} config property.

Payload filtering is not supported with the FDv2 data system, so this
key has no effect on requests made by FDv2 data sources.
"""
return self.__payload_filter_key

Expand Down
4 changes: 4 additions & 0 deletions ldclient/impl/datasystem/async_fdv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def __init__(

self._config = config
self._data_system_config = data_system_config

if config.payload_filter_key is not None:
log.warning("Payload filtering is not supported with the FDv2 data system; the configured payload filter has no effect on FDv2 requests")

self._synchronizers: List[DataSourceBuilder[AsyncSynchronizer]] = list(data_system_config.synchronizers) if data_system_config.synchronizers else []
self._fdv1_fallback_synchronizer_builder = data_system_config.fdv1_fallback_synchronizer
self._disabled = config.offline
Expand Down
4 changes: 4 additions & 0 deletions ldclient/impl/datasystem/fdv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def __init__(

self._config = config
self._data_system_config = data_system_config

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase or merge in main to your branch. Its out of date and missing the async fdv2 file where this warning should also be added.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged main in and added the same warning (plus tests) to AsyncFDv2.__init__ in ldclient/impl/datasystem/async_fdv2.py. The AsyncConfig.payload_filter_key docs were already updated in the original commit.

if config.payload_filter_key is not None:
log.warning("Payload filtering is not supported with the FDv2 data system; the configured payload filter has no effect on FDv2 requests")

self._synchronizers: List[DataSourceBuilder[Synchronizer]] = list(data_system_config.synchronizers) if data_system_config.synchronizers else []
self._fdv1_fallback_synchronizer_builder = data_system_config.fdv1_fallback_synchronizer
self._disabled = config.offline
Expand Down
15 changes: 15 additions & 0 deletions ldclient/testing/impl/datasystem/test_async_fdv2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pylint: disable=missing-docstring

import asyncio
import logging
from typing import Any, AsyncGenerator, Dict, List, Mapping, Optional

import pytest
Expand Down Expand Up @@ -778,3 +779,17 @@ async def test_successful_ops_pass_through():
assert got is not None and got["key"] == "flag-a"
allf = await wrapper.all(FEATURES)
assert "flag-a" in allf


def test_warns_when_payload_filter_key_is_configured(caplog):
caplog.set_level(logging.WARNING, logger="ldclient.util")
AsyncFDv2(AsyncConfig(sdk_key="dummy", payload_filter_key="microservice-1"), DataSystemConfig(initializers=None, synchronizers=None))

assert any("Payload filtering is not supported with the FDv2 data system" in record.message for record in caplog.records)


def test_does_not_warn_when_payload_filter_key_is_not_configured(caplog):
caplog.set_level(logging.WARNING, logger="ldclient.util")
AsyncFDv2(AsyncConfig(sdk_key="dummy"), DataSystemConfig(initializers=None, synchronizers=None))

assert not any("Payload filtering" in record.message for record in caplog.records)
15 changes: 15 additions & 0 deletions ldclient/testing/impl/datasystem/test_fdv2_datasystem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pylint: disable=missing-docstring

import logging
import os
import tempfile
from threading import Event
Expand Down Expand Up @@ -846,3 +847,17 @@ def test_environment_id_is_not_recorded_from_non_valid_updates():

assert fdv2.environment_id == "env-from-sync"
fdv2.stop()


def test_warns_when_payload_filter_key_is_configured(caplog):
caplog.set_level(logging.WARNING, logger="ldclient.util")
FDv2(Config(sdk_key="dummy", payload_filter_key="microservice-1"), DataSystemConfig(initializers=None, synchronizers=None))

assert any("Payload filtering is not supported with the FDv2 data system" in record.message for record in caplog.records)


def test_does_not_warn_when_payload_filter_key_is_not_configured(caplog):
caplog.set_level(logging.WARNING, logger="ldclient.util")
FDv2(Config(sdk_key="dummy"), DataSystemConfig(initializers=None, synchronizers=None))

assert not any("Payload filtering" in record.message for record in caplog.records)
Loading