From eca6497fd21bfb9dd5cdda864227cad63ce04206 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 3 Sep 2026 20:59:32 +0000 Subject: [PATCH] feat: warn that payload filtering has no effect with FDv2 Payload filtering is not supported with the FDv2 data system. Document that on the shared payloadFilterKey option and log a warning when it is configured alongside an FDv2 data system. Co-Authored-By: Bee Klimt --- .../datasource/FDv2DataManagerBase.test.ts | 32 +++++++++ .../shared/sdk-client/src/api/LDOptions.ts | 3 + .../src/datasource/FDv2DataManagerBase.ts | 7 ++ .../LDClientImpl.payloadFilter.test.ts | 70 +++++++++++++++++++ .../shared/sdk-server/src/LDClientImpl.ts | 7 ++ .../sdk-server/src/api/options/LDOptions.ts | 3 + 6 files changed, 122 insertions(+) create mode 100644 packages/shared/sdk-server/__tests__/LDClientImpl.payloadFilter.test.ts diff --git a/packages/shared/sdk-client/__tests__/datasource/FDv2DataManagerBase.test.ts b/packages/shared/sdk-client/__tests__/datasource/FDv2DataManagerBase.test.ts index ac1372e8a0..cb3f4e3dbd 100644 --- a/packages/shared/sdk-client/__tests__/datasource/FDv2DataManagerBase.test.ts +++ b/packages/shared/sdk-client/__tests__/datasource/FDv2DataManagerBase.test.ts @@ -1153,3 +1153,35 @@ it('populates polling and streaming config in the factory context', async () => manager.close(); }); + +it('warns when a payload filter key is configured', () => { + const config = makeConfig({ + serviceEndpoints: new ServiceEndpoints( + 'https://stream', + 'https://poll', + 'https://events', + '/bulk', + '/diagnostic', + true, + 'microservice-1', + ), + }); + + const manager = createFDv2DataManagerBase(makeBaseConfig({ config })); + + expect(config.logger.warn).toHaveBeenCalledWith( + expect.stringContaining('Payload filtering is not supported with the FDv2 data system'), + ); + + manager.close(); +}); + +it('does not warn when no payload filter key is configured', () => { + const config = makeConfig(); + + const manager = createFDv2DataManagerBase(makeBaseConfig({ config })); + + expect(config.logger.warn).not.toHaveBeenCalled(); + + manager.close(); +}); diff --git a/packages/shared/sdk-client/src/api/LDOptions.ts b/packages/shared/sdk-client/src/api/LDOptions.ts index e7841d07e5..fc727c16c6 100644 --- a/packages/shared/sdk-client/src/api/LDOptions.ts +++ b/packages/shared/sdk-client/src/api/LDOptions.ts @@ -249,6 +249,9 @@ export interface LDOptions { * 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 featureStore * 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. */ payloadFilterKey?: string; diff --git a/packages/shared/sdk-client/src/datasource/FDv2DataManagerBase.ts b/packages/shared/sdk-client/src/datasource/FDv2DataManagerBase.ts index 0ec81709dc..41c092f10e 100644 --- a/packages/shared/sdk-client/src/datasource/FDv2DataManagerBase.ts +++ b/packages/shared/sdk-client/src/datasource/FDv2DataManagerBase.ts @@ -137,6 +137,13 @@ export function createFDv2DataManagerBase( } = baseConfig; const { logger } = config; + + if (config.serviceEndpoints.payloadFilterKey !== undefined) { + logger?.warn( + `${logTag} Payload filtering is not supported with the FDv2 data system; the configured payload filter has no effect on FDv2 requests`, + ); + } + const statusManager: DataSourceStatusManager = createDataSourceStatusManager(emitter); const endpoints = fdv2Endpoints(); diff --git a/packages/shared/sdk-server/__tests__/LDClientImpl.payloadFilter.test.ts b/packages/shared/sdk-server/__tests__/LDClientImpl.payloadFilter.test.ts new file mode 100644 index 0000000000..a636415d67 --- /dev/null +++ b/packages/shared/sdk-server/__tests__/LDClientImpl.payloadFilter.test.ts @@ -0,0 +1,70 @@ +import { LDLogger } from '@launchdarkly/js-sdk-common'; + +import { LDOptions } from '../src/api/options/LDOptions'; +import LDClientImpl from '../src/LDClientImpl'; +import { createBasicPlatform } from './createBasicPlatform'; + +describe('given a client using the FDv2 data system', () => { + const callbacks = { + onFailed: jest.fn(), + onError: jest.fn(), + onReady: jest.fn(), + onUpdate: jest.fn(), + hasEventListeners: jest.fn(), + }; + let platform: any; + let logger: LDLogger; + let client: LDClientImpl; + + function makeOptions(overrides: LDOptions = {}): LDOptions { + return { + sendEvents: false, + diagnosticOptOut: true, + logger, + dataSystem: { + dataSource: { + dataSourceOptionsType: 'custom', + initializers: [], + synchronizers: [], + }, + }, + ...overrides, + }; + } + + beforeEach(() => { + platform = createBasicPlatform(); + logger = { + error: jest.fn(), + warn: jest.fn(), + info: jest.fn(), + debug: jest.fn(), + }; + }); + + afterEach(() => { + client?.close(); + jest.resetAllMocks(); + }); + + it('warns when a payload filter key is configured', () => { + client = new LDClientImpl( + 'sdk-key', + platform, + makeOptions({ payloadFilterKey: 'microservice-1' }), + callbacks, + ); + + expect(logger.warn).toHaveBeenCalledWith( + expect.stringContaining('Payload filtering is not supported with the FDv2 data system'), + ); + }); + + it('does not warn when no payload filter key is configured', () => { + client = new LDClientImpl('sdk-key', platform, makeOptions(), callbacks); + + expect(logger.warn).not.toHaveBeenCalledWith( + expect.stringContaining('Payload filtering is not supported'), + ); + }); +}); diff --git a/packages/shared/sdk-server/src/LDClientImpl.ts b/packages/shared/sdk-server/src/LDClientImpl.ts index f27e8e49ac..ff16cc1563 100644 --- a/packages/shared/sdk-server/src/LDClientImpl.ts +++ b/packages/shared/sdk-server/src/LDClientImpl.ts @@ -302,6 +302,13 @@ function constructFDv2( } const { logger } = config; + + if (config.payloadFilterKey !== undefined) { + logger?.warn( + 'Payload filtering is not supported with the FDv2 data system; the configured payload filter has no effect on FDv2 requests', + ); + } + const baseHeaders = defaultHeaders( sdkKey, platform.info, diff --git a/packages/shared/sdk-server/src/api/options/LDOptions.ts b/packages/shared/sdk-server/src/api/options/LDOptions.ts index 205ad771d2..2f3e25f207 100644 --- a/packages/shared/sdk-server/src/api/options/LDOptions.ts +++ b/packages/shared/sdk-server/src/api/options/LDOptions.ts @@ -328,6 +328,9 @@ export interface LDOptions { * 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 featureStore * 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. */ payloadFilterKey?: string;