Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(batch-exports): drop stale config fields from destination PATCH (#63955)

Rosse9ef4451bf05
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts
index 5ac32268240b..8f1b58fc6491 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts
+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts
@@ -108,6 +108,24 @@ const BIGQUERY_BATCH_EXPORT = fixture('test-bq-id', 'BigQuery Export', {
},
})
+// A BigQuery export whose stored config still carries pre-Integration leftovers: the frontend-only
+// `json_config_file` and credentials that now live on the integration. These must be stripped on
+// save — the backend rejects any config key not on the destination's allowlist.
+const BIGQUERY_STALE_BATCH_EXPORT = fixture('test-bq-stale-id', 'BigQuery Stale Export', {
+ type: 'BigQuery',
+ integration: 7,
+ config: {
+ dataset_id: 'test_dataset',
+ table_id: 'events',
+ use_json_type: false,
+ exclude_events: [],
+ include_events: [],
+ json_config_file: [{}],
+ private_key: 'stale-private-key',
+ project_id: 'stale-project',
+ } as any,
+})
+
const POSTGRES_BATCH_EXPORT = fixture('fixture-postgres', 'Postgres Export', {
type: 'Postgres',
config: {
@@ -287,6 +305,7 @@ const ALL_BATCH_EXPORTS: BatchExportConfiguration[] = [
AWS_S3_BATCH_EXPORT,
S3_COMPATIBLE_BATCH_EXPORT,
BIGQUERY_BATCH_EXPORT,
+ BIGQUERY_STALE_BATCH_EXPORT,
POSTGRES_BATCH_EXPORT,
SNOWFLAKE_PASSWORD_BATCH_EXPORT,
SNOWFLAKE_KEYPAIR_BATCH_EXPORT,
@@ -993,4 +1012,29 @@ describe('batchExportConfigFormLogic', () => {
expect(body.destination).toEqual(fixture.destination)
})
})
+
+ describe('strips stale/legacy config fields not in the destination allowlist', () => {
+ // Pre-Integration BigQuery configs can still hold json_config_file + credential fields.
+ // Editing such an export must not re-send them, or the backend rejects the PATCH with
+ // "Configuration has unknown field/s".
+ it('drops pre-Integration BigQuery fields from the PATCH payload', async () => {
+ await initLogic({ service: null, id: BIGQUERY_STALE_BATCH_EXPORT.id })
+
+ await expectLogic(logic, () => {
+ logic.actions.submitConfiguration()
+ })
+ .toDispatchActions(['submitConfiguration', 'updateBatchExportConfigSuccess'])
+ .toFinishAllListeners()
+
+ const body = patchBodiesById[BIGQUERY_STALE_BATCH_EXPORT.id]
+ expect(body).not.toBeUndefined()
+ expect(body.destination.config).toEqual({
+ dataset_id: 'test_dataset',
+ table_id: 'events',
+ use_json_type: false,
+ exclude_events: [],
+ include_events: [],
+ })
+ })
+ })
})
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx
index 7d127c84c196..73bf41006129 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx
@@ -46,6 +46,8 @@ const TOP_LEVEL_FORM_FIELDS = new Set([
'integration_id',
])
+const ALLOWED_BASE_CONFIG_KEYS = new Set(['exclude_events', 'include_events'])
+
function buildDestinationPayload(formValues: Record<string, any>): {
type: string
config: Record<string, any>
@@ -56,13 +58,19 @@ function buildDestinationPayload(formValues: Record<string, any>): {
// Apply destination-specific transform first (e.g. Redshift's COPY copy_inputs assembly).
// Destinations without a custom serialize get the raw form values passed through.
const intermediate = definition?.serialize ? definition.serialize(formValues) : formValues
- // Strip top-level form fields that don't belong in destination.config (always — destinations
- // shouldn't have to re-implement this).
+ // When a destination declares configKeys, drop any config key outside it (plus the base-export
+ // keys). Mirrors the backend's allowed = destination_fields ∪ base_field_names check, so stale
+ // fields don't survive a deserialize → serialize round-trip and get rejected on save.
+ const allowed = definition?.configKeys ? new Set([...definition.configKeys, ...ALLOWED_BASE_CONFIG_KEYS]) : null
+ // Strip top-level form fields that don't belong in destination.config
const config: Record<string, any> = {}
for (const [key, value] of Object.entries(intermediate)) {
if (TOP_LEVEL_FORM_FIELDS.has(key)) {
continue
}
+ if (allowed && !allowed.has(key)) {
+ continue
+ }
config[key] = value
}
const result: { type: string; config: Record<string, any>; integration?: any } = {
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/azureblob.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/azureblob.tsx
index 513727eca980..f8ab576168b6 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/azureblob.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/azureblob.tsx
@@ -14,6 +14,7 @@ export const azureBlobDefinition: DestinationDefinition = {
compression: 'zstd',
}),
requiredFields: ({ isNew }) => ['integration_id', 'container_name', ...(isNew ? ['file_format'] : [])],
+ configKeys: ['container_name', 'prefix', 'compression', 'file_format', 'max_file_size_mb'],
validate: (formValues) => ({
container_name: validateAzureContainerName(formValues.container_name),
}),
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/bigquery.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/bigquery.tsx
index 95ec63264d08..e4fb3741f0fd 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/bigquery.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/bigquery.tsx
@@ -10,7 +10,9 @@ export const bigqueryDefinition: DestinationDefinition = {
type: 'BigQuery',
usesIntegration: true,
defaults: () => ({}),
- requiredFields: ({ isNew }) => [...(isNew ? ['integration_id'] : []), 'dataset_id', 'table_id'],
+ requiredFields: () => ['integration_id', 'dataset_id', 'table_id'],
+ // Credentials and project_id now live on the integration; json_config_file is a removed legacy field.
+ configKeys: ['dataset_id', 'table_id', 'use_json_type'],
eventTableOverrides: { teamIdHogql: 'team_id' },
eventTableExtraFields: {
bq_ingested_timestamp: {
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/databricks.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/databricks.tsx
index 38a2e1f68137..a1be897f79e6 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/databricks.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/databricks.tsx
@@ -15,6 +15,7 @@ export const databricksDefinition: DestinationDefinition = {
http_path: '/sql/1.0/warehouses/',
}),
requiredFields: () => ['integration_id', 'http_path', 'catalog', 'schema', 'table_name'],
+ configKeys: ['http_path', 'catalog', 'schema', 'table_name', 'use_variant_type', 'use_automatic_schema_evolution'],
eventTableExtraFields: {
team_id: {
name: 'team_id',
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/types.ts b/frontend/src/scenes/data-pipelines/batch-exports/destinations/types.ts
index c61f0d0d12a6..e219cdf2726f 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/types.ts
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/types.ts
@@ -27,6 +27,12 @@ export interface DestinationDefinition {
validate?: (formValues: Record<string, any>) => Record<string, string | undefined>
// Form fields → API destination.config payload. Default behaviour: pass remaining fields through unchanged.
serialize?: (formValues: Record<string, any>) => Record<string, any>
+ // Allowlist of valid destination.config keys (mirrors the backend workflow-inputs dataclass in
+ // products/batch_exports/backend/service.py, destination-specific fields only). When set,
+ // buildDestinationPayload drops any other key — guards against stale/legacy fields being
+ // re-sent and rejected by the backend. Omit to keep pass-through behaviour.
+ // TODO: ideally we could get this from the backend
+ configKeys?: string[]
// API destination.config → flat form fields. Default: spread.
deserialize?: (config: Record<string, any>) => Record<string, any>
// Extra columns added to the events table preview for this destination.