: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(batch-exports): remove the legacy S3 destination type (#107607)
Ross08917c3ad586
diff --git a/products/batch_exports/backend/api/batch_export.py b/products/batch_exports/backend/api/batch_export.pyindex 70421c02a918..6433b91e80d1 100644--- a/products/batch_exports/backend/api/batch_export.py+++ b/products/batch_exports/backend/api/batch_export.py@@ -1467,14 +1467,6 @@ class BatchExportSerializer(serializers.ModelSerializer):"export, or turned back on once an export moved to the standard '.parquet' extension.")- # The legacy `S3` type predates both the AwsS3/S3Compatible split and integration-backed- # credentials. Every row has been migrated off it, so it accepts no writes at all.- if destination_type == BatchExportDestination.Destination.S3:- raise serializers.ValidationError(- "The 'S3' destination type is deprecated and can no longer be used. "- "Use 'AwsS3' for AWS S3, or 'S3Compatible' for S3-compatible storage."- )-merged_config = recursive_dict_merge(existing_config, config)# SSRF protection for HTTP batch exportsdiff --git a/products/batch_exports/backend/facade/contracts.py b/products/batch_exports/backend/facade/contracts.pyindex c83be3a29f40..e7650544d4ed 100644--- a/products/batch_exports/backend/facade/contracts.py+++ b/products/batch_exports/backend/facade/contracts.py@@ -32,7 +32,6 @@ BATCH_EXPORT_MODEL_LABEL = "batch_exports.BatchExport"class DestinationType(StrEnum):- S3 = "S3"AWS_S3 = "AwsS3"S3_COMPATIBLE = "S3Compatible"SNOWFLAKE = "Snowflake"diff --git a/products/batch_exports/backend/migrations/0010_alter_batchexportdestination_type.py b/products/batch_exports/backend/migrations/0010_alter_batchexportdestination_type.pynew file mode 100644index 000000000000..cd946809dd29--- /dev/null+++ b/products/batch_exports/backend/migrations/0010_alter_batchexportdestination_type.py@@ -0,0 +1,34 @@+# Generated by Django 5.2.17 on 2026-09-28 14:34++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("batch_exports", "0009_batchexportsource_hogql_modifiers"),+ ]++ operations = [+ migrations.AlterField(+ model_name="batchexportdestination",+ name="type",+ field=models.CharField(+ choices=[+ ("AwsS3", "Aws S3"),+ ("S3Compatible", "S3 Compatible"),+ ("Snowflake", "Snowflake"),+ ("Postgres", "Postgres"),+ ("Redshift", "Redshift"),+ ("BigQuery", "Bigquery"),+ ("Databricks", "Databricks"),+ ("AzureBlob", "Azure Blob"),+ ("Workflows", "Workflows"),+ ("HTTP", "Http"),+ ("NoOp", "Noop"),+ ("FileDownload", "File Download"),+ ],+ help_text="A choice of supported BatchExportDestination types.",+ max_length=64,+ ),+ ),+ ]diff --git a/products/batch_exports/backend/migrations/max_migration.txt b/products/batch_exports/backend/migrations/max_migration.txtindex 8dbef9ea31b7..6c8cf523aabc 100644--- a/products/batch_exports/backend/migrations/max_migration.txt+++ b/products/batch_exports/backend/migrations/max_migration.txt@@ -1 +1 @@-0009_batchexportsource_hogql_modifiers+0010_alter_batchexportdestination_typediff --git a/products/batch_exports/backend/models/batch_export.py b/products/batch_exports/backend/models/batch_export.pyindex 9103e3328bb2..0de5f2d87130 100644--- a/products/batch_exports/backend/models/batch_export.py+++ b/products/batch_exports/backend/models/batch_export.py@@ -24,8 +24,6 @@ from posthog.models.utils import UUIDTModel# (we could use common_timezones instead; this has 433 timezones vs 596 for all_timezones)TIMEZONES = [(tz, tz) for tz in pytz.all_timezones]-# S3-family destination types that are in use. Note that this excludes the legacy "S3"-# type which has now been fully deprecated.S3_FAMILY_TYPES: frozenset[str] = frozenset({"AwsS3", "S3Compatible"})# Destinations that write files to object storage, as opposed to the data warehouse destinations@@ -35,7 +33,7 @@ S3_FAMILY_TYPES: frozenset[str] = frozenset({"AwsS3", "S3Compatible"})# Also includes "FileDownload", which writes to a PostHog bucket rather than a customer one.# TODO: it probably makes sense to introduce a 'DestinationKind' abstraction in the future,# to properly categorize object storage and data warehouse destinations.-OBJECT_STORAGE_DESTINATIONS: frozenset[str] = frozenset({"S3", "AwsS3", "S3Compatible", "AzureBlob", "FileDownload"})+OBJECT_STORAGE_DESTINATIONS: frozenset[str] = frozenset({"AwsS3", "S3Compatible", "AzureBlob", "FileDownload"})class DayOfWeek(IntEnum):@@ -75,7 +73,6 @@ class BatchExportDestination(UUIDTModel):class Destination(models.TextChoices):"""Enumeration of supported destinations for PostHog BatchExports."""- S3 = "S3" # TODO: legacy alias which is no longer used so can be removedAWS_S3 = "AwsS3"S3_COMPATIBLE = "S3Compatible"SNOWFLAKE = "Snowflake"@@ -93,7 +90,6 @@ class BatchExportDestination(UUIDTModel):# credentials still hold them in `config`. These entries keep those stale values out of API# responses until a follow-up strips them from stored config.secret_fields = {- "S3": {"aws_access_key_id", "aws_secret_access_key"},"AwsS3": {"aws_access_key_id", "aws_secret_access_key"},"S3Compatible": {"aws_access_key_id", "aws_secret_access_key"},"Snowflake": {"user", "password", "private_key", "private_key_passphrase"},diff --git a/products/batch_exports/backend/service.py b/products/batch_exports/backend/service.pyindex 6a97da676969..01c5fd1bc461 100644--- a/products/batch_exports/backend/service.py+++ b/products/batch_exports/backend/service.py@@ -263,13 +263,11 @@ class BaseBatchExportInputs:class S3BatchExportInputs(BaseBatchExportInputs):"""Inputs for S3 export workflow.- This is the canonical input dataclass consumed by the `s3-export` Temporal- workflow and is the superset of every S3-family destination's fields. The- legacy `type="S3"` batch exports dispatch with this dataclass directly; the- refined S3-family types (AwsS3, S3Compatible) dispatch with their own- narrower dataclass — Temporal's data converter serializes that to JSON,- and on the worker side deserializes into `S3BatchExportInputs`, with any- missing fields falling through to the defaults declared here.+ This is the input dataclass the `s3-export` Temporal workflow declares, and it holds the+ union of every S3-family destination's fields. No destination type dispatches with it;+ each type dispatches with its own narrower dataclass. Temporal's data converter serializes+ that dataclass to JSON, and the worker deserializes it into this one. A field the narrower+ dataclass does not declare therefore takes the default declared here.Credentials and the provider endpoint are never carried here: the activity resolves them fromthe linked Integration at run time (see `integration_id`).@@ -559,9 +557,6 @@ DESTINATION_WORKFLOWS = {"NoOp": ("no-op", NoOpInputs),"Postgres": ("postgres-export", PostgresBatchExportInputs),"Redshift": ("redshift-export", RedshiftBatchExportInputs),- # "S3" is the legacy alias still accepted on input and persisted as-is.- # AwsS3 and S3Compatible are the refined types preferred for new rows- "S3": ("s3-export", S3BatchExportInputs),"S3Compatible": ("s3-export", S3CompatibleBatchExportInputs),"Snowflake": ("snowflake-export", SnowflakeBatchExportInputs),"Workflows": ("workflows-export", WorkflowsBatchExportInputs),diff --git a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py b/products/batch_exports/backend/temporal/destinations/s3_batch_export.pyindex 2e32da75e4eb..910a642ef73e 100644--- a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/s3_batch_export.py@@ -302,11 +302,11 @@ def s3_default_fields() -> list[BatchExportField]:class S3BatchExportWorkflow(PostHogWorkflow):"""A Temporal Workflow to export ClickHouse data into S3 or any S3-compatible bucket.- This Workflow is shared across every S3-family destination — `AwsS3`, `S3Compatible`,- and the legacy `S3` alias. The API surface validates per-destination input dataclasses- (`AwsS3BatchExportInputs`, `S3CompatibleBatchExportInputs`); Temporal's data converter- serializes them to JSON, and on deserialization fields not present on the narrower- input class fall through to their `S3BatchExportInputs` defaults.+ This Workflow is shared by the `AwsS3` and `S3Compatible` destinations. The API surface+ validates per-destination input dataclasses (`AwsS3BatchExportInputs`,+ `S3CompatibleBatchExportInputs`); Temporal's data converter serializes them to JSON, and on+ deserialization fields not present on the narrower input class fall through to their+ `S3BatchExportInputs` defaults.This Workflow is intended to be executed both manually and by a Temporal Schedule.When ran by a schedule, `data_interval_end` should be set to `None` so that we will fetch thediff --git a/products/batch_exports/backend/tests/api/test_create_s3.py b/products/batch_exports/backend/tests/api/test_create_s3.pyindex 70929f7ccc5b..17879a9028f4 100644--- a/products/batch_exports/backend/tests/api/test_create_s3.py+++ b/products/batch_exports/backend/tests/api/test_create_s3.py@@ -83,24 +83,6 @@ def test_create_s3_family_batch_export_requires_an_integration(assert response.json()["detail"] == f"Integration is required for {destination_type} batch exports"-def test_create_legacy_s3_type_is_rejected(client: HttpClient, temporal, organization, team, user):- """The legacy `S3` type is deprecated and can no longer be created via the API."""- client.force_login(user)- response = create_batch_export(- client,- team.pk,- {- "name": "my-export",- "interval": "hour",- "destination": {"type": "S3", "config": {**_S3_FAMILY_BASE_CONFIG}},- },- )- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()- assert "deprecated" in response.json()["detail"]- assert "AwsS3" in response.json()["detail"]- assert "S3Compatible" in response.json()["detail"]--@pytest.mark.parametrize("destination_type,integration_fixture",[diff --git a/products/batch_exports/backend/tests/api/test_update_s3.py b/products/batch_exports/backend/tests/api/test_update_s3.pyindex eb73f823eb7a..fff5b4adb8c6 100644--- a/products/batch_exports/backend/tests/api/test_update_s3.py+++ b/products/batch_exports/backend/tests/api/test_update_s3.py@@ -7,7 +7,6 @@ from rest_framework import statusfrom posthog.models.integration import Integrationfrom products.batch_exports.backend.models.batch_export import BatchExportDestination-from products.batch_exports.backend.tests.api.fixtures import create_batch_export as create_batch_export_ormfrom products.batch_exports.backend.tests.api.operations import create_batch_export_ok, patch_batch_exportpytestmark = [@@ -133,31 +132,6 @@ def test_updating_migrated_s3_batch_export_ignores_credentials_left_in_stored_coassert response.json()["destination"]["config"]["prefix"] == "new-prefix/"-def test_updating_legacy_s3_batch_export_is_rejected(client: HttpClient, temporal, organization, team, user):- """The legacy `S3` type has been migrated away and accepts no writes."""- destination = BatchExportDestination.objects.create(- type="S3",- config={- "bucket_name": "my-s3-bucket",- "region": "us-east-1",- "prefix": "events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- )- batch_export = create_batch_export_orm(team, destination)-- client.force_login(user)- response = patch_batch_export(- client,- team.pk,- str(batch_export.id),- {"destination": {"type": "S3", "config": {"prefix": "new-prefix/"}}},- )- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()- assert "deprecated" in response.json()["detail"]--def test_updating_s3_family_batch_export_preserves_legacy_parquet_extension(client: HttpClient, temporal, organization, team, user):diff --git a/products/batch_exports/frontend/generated/api.schemas.ts b/products/batch_exports/frontend/generated/api.schemas.tsindex 31cb1e849f8a..7c07dda6a429 100644--- a/products/batch_exports/frontend/generated/api.schemas.ts+++ b/products/batch_exports/frontend/generated/api.schemas.ts@@ -29,7 +29,6 @@ export const BlankEnumApi = {} as const/**- * * `S3` - S3* * `AwsS3` - Aws S3* * `S3Compatible` - S3 Compatible* * `Snowflake` - Snowflake@@ -47,7 +46,6 @@ export type BatchExportDestinationDestinationEnumApi =(typeof BatchExportDestinationDestinationEnumApi)[keyof typeof BatchExportDestinationDestinationEnumApi]export const BatchExportDestinationDestinationEnumApi = {- S3: 'S3',AwsS3: 'AwsS3',S3Compatible: 'S3Compatible',Snowflake: 'Snowflake',@@ -461,7 +459,6 @@ export type BatchExportDestinationConfigApi =export interface BatchExportDestinationApi {/** A choice of supported BatchExportDestination types.*- * * `S3` - S3* * `AwsS3` - Aws S3* * `S3Compatible` - S3 Compatible* * `Snowflake` - Snowflakediff --git a/products/batch_exports/frontend/generated/api.zod.ts b/products/batch_exports/frontend/generated/api.zod.tsindex ee3058d2bf28..22ed1c98c70c 100644--- a/products/batch_exports/frontend/generated/api.zod.ts+++ b/products/batch_exports/frontend/generated/api.zod.ts@@ -1714,7 +1714,6 @@ export const BatchExportsRunTestStepCreateBody = /* @__PURE__ */ zod.object({type: zod.enum([- 'S3','AwsS3','S3Compatible','Snowflake',@@ -1729,10 +1728,10 @@ export const BatchExportsRunTestStepCreateBody = /* @__PURE__ */ zod'FileDownload',]).describe(- '\* `S3` - S3\n\* `AwsS3` - Aws S3\n\* `S3Compatible` - S3 Compatible\n\* `Snowflake` - Snowflake\n\* `Postgres` - Postgres\n\* `Redshift` - Redshift\n\* `BigQuery` - Bigquery\n\* `Databricks` - Databricks\n\* `AzureBlob` - Azure Blob\n\* `Workflows` - Workflows\n\* `HTTP` - Http\n\* `NoOp` - Noop\n\* `FileDownload` - File Download'+ '\* `AwsS3` - Aws S3\n\* `S3Compatible` - S3 Compatible\n\* `Snowflake` - Snowflake\n\* `Postgres` - Postgres\n\* `Redshift` - Redshift\n\* `BigQuery` - Bigquery\n\* `Databricks` - Databricks\n\* `AzureBlob` - Azure Blob\n\* `Workflows` - Workflows\n\* `HTTP` - Http\n\* `NoOp` - Noop\n\* `FileDownload` - File Download').describe(- 'A choice of supported BatchExportDestination types.\n\n\* `S3` - S3\n\* `AwsS3` - Aws S3\n\* `S3Compatible` - S3 Compatible\n\* `Snowflake` - Snowflake\n\* `Postgres` - Postgres\n\* `Redshift` - Redshift\n\* `BigQuery` - Bigquery\n\* `Databricks` - Databricks\n\* `AzureBlob` - Azure Blob\n\* `Workflows` - Workflows\n\* `HTTP` - Http\n\* `NoOp` - Noop\n\* `FileDownload` - File Download'+ 'A choice of supported BatchExportDestination types.\n\n\* `AwsS3` - Aws S3\n\* `S3Compatible` - S3 Compatible\n\* `Snowflake` - Snowflake\n\* `Postgres` - Postgres\n\* `Redshift` - Redshift\n\* `BigQuery` - Bigquery\n\* `Databricks` - Databricks\n\* `AzureBlob` - Azure Blob\n\* `Workflows` - Workflows\n\* `HTTP` - Http\n\* `NoOp` - Noop\n\* `FileDownload` - File Download'),config: zod.union([@@ -2191,7 +2190,6 @@ export const BatchExportsRunTestStepNewCreateBody = /* @__PURE__ */ zod.object({type: zod.enum([- 'S3','AwsS3','S3Compatible','Snowflake',@@ -2206,10 +2204,10 @@ export const BatchExportsRunTestStepNewCreateBody = /* @__PURE__ */ zod'FileDownload',]).describe(- '\* `S3` - S3\n\* `AwsS3` - Aws S3\n\* `S3Compatible` - S3 Compatible\n\* `Snowflake` - Snowflake\n\* `Postgres` - Postgres\n\* `Redshift` - Redshift\n\* `BigQuery` - Bigquery\n\* `Databricks` - Databricks\n\* `AzureBlob` - Azure Blob\n\* `Workflows` - Workflows\n\* `HTTP` - Http\n\* `NoOp` - Noop\n\* `FileDownload` - File Download'+ '\* `AwsS3` - Aws S3\n\* `S3Compatible` - S3 Compatible\n\* `Snowflake` - Snowflake\n\* `Postgres` - Postgres\n\* `Redshift` - Redshift\n\* `BigQuery` - Bigquery\n\* `Databricks` - Databricks\n\* `AzureBlob` - Azure Blob\n\* `Workflows` - Workflows\n\* `HTTP` - Http\n\* `NoOp` - Noop\n\* `FileDownload` - File Download').describe(- 'A choice of supported BatchExportDestination types.\n\n\* `S3` - S3\n\* `AwsS3` - Aws S3\n\* `S3Compatible` - S3 Compatible\n\* `Snowflake` - Snowflake\n\* `Postgres` - Postgres\n\* `Redshift` - Redshift\n\* `BigQuery` - Bigquery\n\* `Databricks` - Databricks\n\* `AzureBlob` - Azure Blob\n\* `Workflows` - Workflows\n\* `HTTP` - Http\n\* `NoOp` - Noop\n\* `FileDownload` - File Download'+ 'A choice of supported BatchExportDestination types.\n\n\* `AwsS3` - Aws S3\n\* `S3Compatible` - S3 Compatible\n\* `Snowflake` - Snowflake\n\* `Postgres` - Postgres\n\* `Redshift` - Redshift\n\* `BigQuery` - Bigquery\n\* `Databricks` - Databricks\n\* `AzureBlob` - Azure Blob\n\* `Workflows` - Workflows\n\* `HTTP` - Http\n\* `NoOp` - Noop\n\* `FileDownload` - File Download'),config: zod.union([diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 5321817d7f17..3e79135cefc4 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -13791,7 +13791,6 @@ export namespace Schemas {} as const;/**- * * `S3` - S3* * `AwsS3` - Aws S3* * `S3Compatible` - S3 Compatible* * `Snowflake` - Snowflake@@ -13809,7 +13808,6 @@ export namespace Schemas {export const BatchExportDestinationDestinationEnum = {- S3: 'S3',AwsS3: 'AwsS3',S3Compatible: 'S3Compatible',Snowflake: 'Snowflake',@@ -14090,7 +14088,6 @@ export namespace Schemas {export interface BatchExportDestination {/** A choice of supported BatchExportDestination types.*- * * `S3` - S3* * `AwsS3` - Aws S3* * `S3Compatible` - S3 Compatible* * `Snowflake` - Snowflake