diff --git a/lib/ldclient-rb/config.rb b/lib/ldclient-rb/config.rb index 29bd2d66..db0f5e6c 100644 --- a/lib/ldclient-rb/config.rb +++ b/lib/ldclient-rb/config.rb @@ -362,6 +362,9 @@ def offline? # This payload filter key only applies to the default streaming and 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. + # attr_reader :payload_filter_key # diff --git a/lib/ldclient-rb/impl/data_system/fdv2.rb b/lib/ldclient-rb/impl/data_system/fdv2.rb index 860b0238..15994d7e 100644 --- a/lib/ldclient-rb/impl/data_system/fdv2.rb +++ b/lib/ldclient-rb/impl/data_system/fdv2.rb @@ -54,6 +54,11 @@ def initialize(sdk_key, config, data_system_config) @config = config @data_system_config = data_system_config @logger = config.logger + + unless config.payload_filter_key.nil? + @logger.warn { "[LDClient] Payload filtering is not supported with the FDv2 data system; the configured payload filter has no effect on FDv2 requests" } + end + @synchronizer_builders = data_system_config.synchronizers || [] @fdv1_fallback_synchronizer_builder = data_system_config.fdv1_fallback_synchronizer @disabled = @config.offline? diff --git a/spec/impl/data_system/fdv2_datasystem_spec.rb b/spec/impl/data_system/fdv2_datasystem_spec.rb index eb724467..0f2759bc 100644 --- a/spec/impl/data_system/fdv2_datasystem_spec.rb +++ b/spec/impl/data_system/fdv2_datasystem_spec.rb @@ -674,6 +674,29 @@ def build(_sdk_key, _config) fdv2.stop end end + + describe "payload filter key" do + let(:data_system_config) do + LaunchDarkly::DataSystem::ConfigBuilder.new + .initializers([]) + .synchronizers([]) + .build + end + + it "warns when a payload filter key is configured" do + logger = double.as_null_object + expect(logger).to receive(:warn) + + FDv2.new(sdk_key, LaunchDarkly::Config.new(logger: logger, payload_filter_key: "microservice-1"), data_system_config) + end + + it "does not warn when no payload filter key is configured" do + logger = double.as_null_object + expect(logger).not_to receive(:warn) + + FDv2.new(sdk_key, LaunchDarkly::Config.new(logger: logger), data_system_config) + end + end end end end