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.

feat(batch-exports): split S3 destination into AwsS3 and S3Compatible (#57827)

Rossb6faf1e64b8f
diff --git a/posthog/api/test/batch_exports/test_create.py b/posthog/api/test/batch_exports/test_create.py
index 2747bbc8c174..47ae95a7d79b 100644
--- a/posthog/api/test/batch_exports/test_create.py
+++ b/posthog/api/test/batch_exports/test_create.py
@@ -12,7 +12,6 @@ from django.test.client import Client as HttpClient
from asgiref.sync import async_to_sync
from rest_framework import status
-from temporalio.client import ScheduleActionStartWorkflow
from posthog.api.test.batch_exports.conftest import (
assert_is_daily_schedule,
@@ -24,7 +23,6 @@ from posthog.api.test.batch_exports.operations import create_batch_export
from posthog.api.test.test_team import create_team
from posthog.api.test.test_user import create_user
from posthog.batch_exports.models import BatchExport
-from posthog.models.integration import Integration
from posthog.temporal.common.codec import EncryptionCodec
pytestmark = [
@@ -33,6 +31,10 @@ pytestmark = [
]
+# This file holds generic / cross-destination create tests. Per-destination
+# tests live alongside in `test_create_<destination>.py`.
+
+
def test_create_batch_export_with_interval_schedule(client: HttpClient, temporal, organization, team, user):
"""Test creating a BatchExport.
@@ -45,13 +47,14 @@ def test_create_batch_export_with_interval_schedule(client: HttpClient, temporal
interval = "hour"
destination_data = {
- "type": "S3",
+ "type": "S3Compatible",
"config": {
"bucket_name": "my-production-s3-bucket",
"region": "us-east-1",
"prefix": "posthog-events/",
"aws_access_key_id": "abc123",
"aws_secret_access_key": "secret",
+ "endpoint_url": "https://localhost:9000",
"use_virtual_style_addressing": True,
},
"integration": None,
@@ -65,29 +68,11 @@ def test_create_batch_export_with_interval_schedule(client: HttpClient, temporal
client.force_login(user)
- with mock.patch(
- "posthog.batch_exports.http.posthoganalytics.feature_enabled",
- return_value=True,
- ) as feature_enabled:
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- if interval == "every 5 minutes":
- feature_enabled.assert_any_call(
- "high-frequency-batch-exports",
- str(team.uuid),
- groups={"organization": str(team.organization.id)},
- group_properties={
- "organization": {
- "id": str(team.organization.id),
- "created_at": team.organization.created_at,
- }
- },
- send_feature_flag_events=False,
- )
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
assert response.status_code == status.HTTP_201_CREATED, response.json()
@@ -567,391 +552,6 @@ def test_create_batch_export_fails_with_invalid_query(
assert response.json()["detail"] == expected_error_message
- "auth_type,credentials,expected_status",
- [
- # Password auth type tests
- (
- "password",
- {"password": "abc123"},
- status.HTTP_201_CREATED,
- ),
- (
- "password",
- {},
- status.HTTP_400_BAD_REQUEST,
- ),
- # Key pair auth type tests
- (
- "keypair",
- {"private_key": "SECRET_KEY"},
- status.HTTP_201_CREATED,
- ),
- (
- "keypair",
- {},
- status.HTTP_400_BAD_REQUEST,
- ),
- ],
-)
-def test_create_snowflake_batch_export_validates_credentials(
- client: HttpClient, auth_type, credentials, expected_status, temporal, organization, team, user
-):
- """Test creating a BatchExport with Snowflake destination validates credentials based on auth type."""
-
- destination_data = {
- "type": "Snowflake",
- "config": {
- "account": "my-account",
- "user": "user",
- "database": "my-db",
- "warehouse": "COMPUTE_WH",
- "schema": "public",
- "table_name": "my_events",
- "authentication_type": auth_type,
- **credentials,
- },
- }
-
- batch_export_data = {
- "name": "my-production-snowflake-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == expected_status
-
- if expected_status == status.HTTP_400_BAD_REQUEST:
- if auth_type == "password":
- assert "Password is required if authentication type is password" in response.json()["detail"]
- else:
- assert "Private key is required if authentication type is key pair" in response.json()["detail"]
-
-
- "mode,copy_inputs,expected_status",
- [
- (
- "INSERT",
- {},
- status.HTTP_201_CREATED,
- ),
- (
- "INSERT",
- None,
- status.HTTP_201_CREATED,
- ),
- (
- "COPY",
- {
- "s3_bucket": "my-production-s3-bucket",
- "region_name": "us-east-1",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- "authorization": "default",
- },
- status.HTTP_201_CREATED,
- ),
- (
- "COPY",
- {
- "s3_bucket": "my-production-s3-bucket",
- "region_name": "us-east-1",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- "authorization": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- },
- status.HTTP_201_CREATED,
- ),
- # Missing required 's3_bucket'
- (
- "COPY",
- {
- "region_name": "us-east-1",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- "authorization": "default",
- },
- status.HTTP_400_BAD_REQUEST,
- ),
- # Missing required 'region_name'
- (
- "COPY",
- {
- "s3_bucket": "my-production-s3-bucket",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- "authorization": "default",
- },
- status.HTTP_400_BAD_REQUEST,
- ),
- # Missing required 'aws_secret_access_key' in 'bucket_credentials
- (
- "COPY",
- {
- "s3_bucket": "my-production-s3-bucket",
- "region_name": "us-east-1",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {"aws_access_key_id": "abc123"},
- "authorization": "default",
- },
- status.HTTP_400_BAD_REQUEST,
- ),
- # Empty 'bucket_credentials'
- (
- "COPY",
- {
- "s3_bucket": "my-production-s3-bucket",
- "region_name": "us-east-1",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {},
- "authorization": "default",
- },
- status.HTTP_400_BAD_REQUEST,
- ),
- # Empty 'authorization'
- (
- "COPY",
- {
- "s3_bucket": "my-production-s3-bucket",
- "region_name": "us-east-1",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- "authorization": {},
- },
- status.HTTP_400_BAD_REQUEST,
- ),
- # Empty 'authorization' as IAMRole
- (
- "COPY",
- {
- "s3_bucket": "my-production-s3-bucket",
- "region_name": "us-east-1",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- "authorization": "",
- },
- status.HTTP_400_BAD_REQUEST,
- ),
- ],
-)
-def test_create_redshift_batch_export_validates_copy_inputs(
- client: HttpClient, mode, copy_inputs, expected_status, temporal, organization, team, user
-):
- """Test creating a BatchExport with Redshift destination validates inputs for 'COPY'."""
-
- destination_data = {
- "type": "Redshift",
- "config": {
- "user": "user",
- "password": "my-password",
- "database": "my-db",
- "host": "localhost",
- "schema": "public",
- "table_name": "my_events",
- "mode": mode,
- "copy_inputs": copy_inputs,
- },
- }
-
- batch_export_data = {
- "name": "my-production-redshiftn-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == expected_status, response.json()
-
- if expected_status == status.HTTP_400_BAD_REQUEST:
- assert "Missing required" in response.json()["detail"]
-
-
- "file_format,compression,expected_error_message",
- [
- (
- "JSONLines",
- None,
- None,
- ),
- (
- "JSONLines",
- "gzip",
- None,
- ),
- (
- "JSONLines",
- "zstd",
- "Compression zstd is not supported for file format JSONLines. Supported compressions are ['gzip', 'brotli']",
- ),
- (
- "Parquet",
- None,
- None,
- ),
- (
- "Parquet",
- "gzip",
- None,
- ),
- (
- "Parquet",
- "brotli",
- None,
- ),
- (
- "Parquet",
- "zstd",
- None,
- ),
- (
- "Parquet",
- "unknown",
- "Compression unknown is not supported for file format Parquet. Supported compressions are ['zstd', 'lz4', 'snappy', 'gzip', 'brotli']",
- ),
- (
- "unknown",
- "gzip",
- "File format unknown is not supported. Supported file formats are ['Parquet', 'JSONLines']",
- ),
- ],
-)
-def test_create_s3_batch_export_validates_file_format_and_compression(
- client: HttpClient, file_format, compression, expected_error_message, temporal, organization, team, user
-):
- """Test creating a BatchExport with S3 destination validates file format and compression."""
-
- destination_data = {
- "type": "S3",
- "config": {
- "bucket_name": "my-s3-bucket",
- "region": "us-east-1",
- "prefix": "posthog-events/",
- "aws_access_key_id": "abc123",
- "aws_secret_access_key": "secret",
- "file_format": file_format,
- "compression": compression,
- },
- }
-
- batch_export_data = {
- "name": "my-s3-bucket",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- if expected_error_message is None:
- assert response.status_code == status.HTTP_201_CREATED
- else:
- assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert response.json()["detail"] == expected_error_message
-
-
-def test_create_s3_batch_export_validates_empty_inputs(client: HttpClient, temporal, organization, team, user):
- """Test creating a BatchExport with S3 destination validates that expected inputs are not empty."""
-
- destination_data = {
- "type": "S3",
- "config": {
- "bucket_name": "my-s3-bucket",
- "region": "us-east-1",
- "prefix": "events/",
- "aws_access_key_id": "",
- "aws_secret_access_key": "",
- "file_format": "JSONLines",
- "compression": "gzip",
- },
- }
-
- batch_export_data = {
- "name": "my-s3-bucket",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert response.json()["detail"] == "The following inputs are empty: ['aws_access_key_id', 'aws_secret_access_key']"
-
-
-def test_create_s3_batch_export_validates_missing_inputs(client: HttpClient, temporal, organization, team, user):
- """Test creating a BatchExport with S3 destination validates that expected inputs are not missing."""
-
- config = {
- "bucket_name": "my-s3-bucket",
- "region": "us-east-1",
- "prefix": "events/",
- "aws_access_key_id": "something",
- "aws_secret_access_key": "something",
- "file_format": "JSONLines",
- "compression": "gzip",
- }
-
- client.force_login(user)
-
- for key in ("aws_access_key_id", "aws_secret_access_key"):
- # Check that we validate each key missing invidually first
- destination_data = {"type": "S3", "config": {k: v for k, v in config.items() if k != key}}
-
- data = {
- "name": "my-s3-bucket",
- "destination": destination_data,
- "interval": "hour",
- }
-
- response = create_batch_export(
- client,
- team.pk,
- data,
- )
-
- assert response.status_code == status.HTTP_400_BAD_REQUEST, key
- assert response.json()["detail"] == f"Configuration missing required field: '{key}'"
-
- response_missing_both = create_batch_export(
- client,
- team.pk,
- {
- "name": "my-s3-bucket",
- "destination": {k: v for k, v in destination_data.items() if k != "aws_secret_access_key"},
- "interval": "hour",
- },
- )
-
- assert response_missing_both.status_code == status.HTTP_400_BAD_REQUEST
-
-
@pytest.mark.parametrize(
"type,config,expected_error_message",
[
@@ -1036,350 +636,13 @@ def test_create_batch_export_with_invalid_config(
assert expected_error_message in response.json()["detail"]
-def databricks_integration(team, user):
- """Create a Databricks integration."""
- return Integration.objects.create(
- team=team,
- kind=Integration.IntegrationKind.DATABRICKS,
- integration_id="my-server-hostname",
- config={"server_hostname": "my-server-hostname"},
- sensitive_config={"client_id": "my-client-id", "client_secret": "my-client-secret"},
- created_by=user,
- )
-
-
-def test_creating_databricks_batch_export_using_integration(
- client: HttpClient, temporal, organization, team, user, databricks_integration
-):
- """Test that we can create a Databricks batch export using an integration.
-
- Using integrations is the preferred way to handle credentials for batch exports going forward.
- """
-
- destination_data = {
- "type": "Databricks",
- "config": {
- "http_path": "my-http-path",
- "catalog": "my-catalog",
- "schema": "my-schema",
- "table_name": "my-table-name",
- },
- "integration": databricks_integration.id,
- }
-
- batch_export_data = {
- "name": "my-databricks-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == status.HTTP_201_CREATED, response.json()
-
- data = response.json()
- assert data["destination"] == destination_data
-
- schedule = describe_schedule(temporal, data["id"])
- intervals = schedule.schedule.spec.intervals
-
- assert len(intervals) == 1
- assert schedule.schedule.spec.intervals[0].every == dt.timedelta(hours=1)
- assert isinstance(schedule.schedule.action, ScheduleActionStartWorkflow)
- assert schedule.schedule.action.workflow == "databricks-export"
-
-
-def test_creating_databricks_batch_export_fails_if_integration_is_missing(
- client: HttpClient, temporal, organization, team, user
-):
- """Test that creating a Databricks batch export fails if the integration is missing.
-
- Using integrations is the preferred way to handle credentials for batch exports going forward.
- """
-
- destination_data = {
- "type": "Databricks",
- "config": {
- "http_path": "my-http-path",
- "catalog": "my-catalog",
- "schema": "my-schema",
- "table_name": "my-table-name",
- },
- }
-
- batch_export_data = {
- "name": "my-databricks-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
-
- assert response.json() == {
- "type": "validation_error",
- "code": "invalid_input",
- "detail": "Integration is required for Databricks batch exports",
- "attr": "destination",
- }
-
-
-def test_creating_databricks_batch_export_fails_if_integration_is_invalid(
- client: HttpClient, temporal, organization, team, user
-):
- """Test that creating a Databricks batch export fails if the integration is invalid.
-
- Using integrations is the preferred way to handle credentials for batch exports going forward.
-
- In this case, the integration is missing the client_secret. In theory, this shouldn't happen, as we validate the
- integration when creating it via the API.
- """
-
- integration = Integration.objects.create(
- team=team,
- kind=Integration.IntegrationKind.DATABRICKS,
- integration_id="my-server-hostname",
- config={"server_hostname": "my-server-hostname"},
- sensitive_config={"client_id": "my-client-id"},
- created_by=user,
- )
-
- destination_data = {
- "type": "Databricks",
- "config": {
- "http_path": "my-http-path",
- "catalog": "my-catalog",
- "schema": "my-schema",
- "table_name": "my-table-name",
- },
- "integration": integration.pk,
- }
-
- batch_export_data = {
- "name": "my-databricks-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
- assert response.json()["detail"] == "Databricks integration is not valid: 'client_secret' missing"
-
-
-def test_creating_databricks_batch_export_fails_if_integration_does_not_exist(
- client: HttpClient,
- temporal,
- organization,
- team,
- user,
-):
- """Test that creating a Databricks batch export fails if the integration does not exist in the database.
-
- Using integrations is the preferred way to handle credentials for batch exports going forward.
- """
-
- destination_data = {
- "type": "Databricks",
- "config": {
- "http_path": "my-http-path",
- "catalog": "my-catalog",
- "schema": "my-schema",
- "table_name": "my-table-name",
- },
- "integration": 999,
- }
-
- batch_export_data = {
- "name": "my-databricks-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
-
- assert response.json() == {
- "type": "validation_error",
- "code": "does_not_exist",
- "detail": 'Invalid pk "999" - object does not exist.',
- "attr": "destination__integration",
- }
-
-
-def test_creating_databricks_batch_export_fails_if_integration_is_not_the_correct_type(
- client: HttpClient, temporal, organization, team, user
-):
- """Test that creating a Databricks batch export fails if the integration is not the correct type.
-
- Using integrations is the preferred way to handle credentials for batch exports going forward.
-
- In this case, the integration is not a Databricks integration.
- """
-
- integration = Integration.objects.create(
- team=team,
- kind=Integration.IntegrationKind.SLACK,
- integration_id="my-server-hostname",
- config={"server_hostname": "my-server-hostname"},
- sensitive_config={"client_id": "my-client-id"},
- created_by=user,
- )
-
- destination_data = {
- "type": "Databricks",
- "config": {
- "http_path": "my-http-path",
- "catalog": "my-catalog",
- "schema": "my-schema",
- "table_name": "my-table-name",
- },
- "integration": integration.pk,
- }
-
- batch_export_data = {
- "name": "my-databricks-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
- assert response.json()["detail"] == "Integration is not a Databricks integration."
-
-
-def azure_blob_integration(team, user):
- """Create an Azure Blob integration."""
- return Integration.objects.create(
- team=team,
- kind=Integration.IntegrationKind.AZURE_BLOB,
- integration_id="my-storage-account",
- config={},
- sensitive_config={
- "connection_string": "DefaultEndpointsProtocol=https;AccountName=my-storage-account;AccountKey=my-key;EndpointSuffix=core.windows.net"
- },
- created_by=user,
- )
-
-
-def test_creating_azure_blob_batch_export_using_integration(
- client: HttpClient, temporal, organization, team, user, azure_blob_integration
-):
- """Test that we can create an Azure Blob batch export using an integration."""
- destination_data = {
- "type": "AzureBlob",
- "config": {
- "container_name": "test-container",
- "prefix": "test-prefix/",
- },
- "integration": azure_blob_integration.id,
- }
-
- batch_export_data = {
- "name": "my-azure-blob-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == status.HTTP_201_CREATED, response.json()
-
- data = response.json()
- assert data["destination"]["type"] == "AzureBlob"
- assert data["destination"]["config"]["container_name"] == "test-container"
- assert data["destination"]["config"]["prefix"] == "test-prefix/"
- assert data["interval"] == "hour"
-
- temporal_schedule = describe_schedule(temporal, data["id"])
- assert temporal_schedule is not None
- assert temporal_schedule.schedule is not None
- assert isinstance(temporal_schedule.schedule.action, ScheduleActionStartWorkflow)
- assert temporal_schedule.schedule.action.workflow == "azure-blob-export"
-
-
- "model,expected_status,expected_error",
- [
- ("events", status.HTTP_201_CREATED, None),
- (None, status.HTTP_201_CREATED, None),
- ("persons", status.HTTP_400_BAD_REQUEST, "HTTP batch exports only support the events model"),
- ],
-)
-def test_creating_http_batch_export_only_allows_events_model(
- client: HttpClient, temporal, organization, team, user, model, expected_status, expected_error
-):
- """HTTP batch exports are used for migrations, and therefore only support the events model."""
-
- destination_data = {
- "type": "HTTP",
- "config": {
- "url": "https://us.i.posthog.com/batch/",
- "token": "secret-token",
- },
- }
-
- batch_export_data = {
- "name": "my-http-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- if model is not None:
- batch_export_data["model"] = model
-
- client.force_login(user)
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == expected_status, response.json()
-
- if expected_error:
- assert response.json()["detail"] == expected_error
-
-
-_S3_FILTER_TEST_CONFIG = {
- "bucket_name": "my-s3-bucket",
- "region": "us-east-1",
- "prefix": "posthog-events/",
- "aws_access_key_id": "abc123",
- "aws_secret_access_key": "secret",
-}
+_S3_FILTER_TEST_CONFIG = {
+ "bucket_name": "my-s3-bucket",
+ "region": "us-east-1",
+ "prefix": "posthog-events/",
+ "aws_access_key_id": "abc123",
+ "aws_secret_access_key": "secret",
+}
@pytest.mark.parametrize(
@@ -1433,146 +696,6 @@ def test_creating_batch_export_with_filters(
assert expected_error in response.json()["detail"]
-def enable_backfilling_workflows(team):
- with mock.patch(
- "posthog.batch_exports.http.posthoganalytics.feature_enabled", return_value=True
- ) as feature_enabled:
- yield
-
- feature_enabled.assert_any_call(
- "backfill-workflows-destination",
- str(team.uuid),
- groups={"organization": str(team.organization.id)},
- group_properties={
- "organization": {
- "id": str(team.organization.id),
- "created_at": team.organization.created_at,
- }
- },
- send_feature_flag_events=False,
- )
-
-
-def test_creating_workflows_batch_export(
- client: HttpClient, temporal, organization, team, user, enable_backfilling_workflows
-):
- """Test that we can create a Workflows batch export if the feature flag is enabled."""
-
- destination_data = {
- "type": "Workflows",
- "config": {
- "hog_function_id": "aaaa-bbbb-cccc",
- },
- "integration": None,
- }
-
- batch_export_data = {
- "name": "my-workflows-destination",
- "destination": destination_data,
- "interval": "day",
- }
-
- client.force_login(user)
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == status.HTTP_201_CREATED, response.json()
-
- data = response.json()
- assert data["destination"] == destination_data
-
- schedule = describe_schedule(temporal, data["id"])
- assert_is_daily_schedule(schedule, 0)
-
-
-def test_creating_workflows_batch_export_fails_if_feature_flag_is_not_enabled(
- client: HttpClient, temporal, organization, team, user
-):
- """Test that creating a Workflows batch export fails if the feature flag is not enabled."""
-
- destination_data = {
- "type": "Workflows",
- "config": {
- "hog_function_id": "aaaa-bbbb-cccc",
- },
- "integration": None,
- }
-
- batch_export_data = {
- "name": "my-workflows-destination",
- "destination": destination_data,
- "interval": "day",
- }
-
- client.force_login(user)
-
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == status.HTTP_403_FORBIDDEN, response.json()
- assert "Backfilling Workflows is not enabled for this team." in response.json()["detail"]
-
-
- "endpoint_url",
- [
- "https://192.168.1.1",
- "http://127.0.0.1",
- "http://[::1]/",
- "http://10.0.0.1:9000/",
- "http://169.254.0.0:8080/data",
- "http://localhost",
- ],
-)
-def test_creating_S3_batch_export_fails_if_using_invalid_endpoint_url(
- client: HttpClient, temporal, organization, team, user, endpoint_url
-):
- """Test that creating an S3 batch export fails if passing an internal IP as endpoint URL.
-
- Last time I checked, we are not S3.
- """
-
- interval = "hour"
-
- destination_data = {
- "type": "S3",
- "config": {
- "bucket_name": "my-production-s3-bucket",
- "region": "us-east-1",
- "prefix": "posthog-events/",
- "aws_access_key_id": "abc123",
- "aws_secret_access_key": "secret",
- "use_virtual_style_addressing": True,
- "endpoint_url": endpoint_url,
- },
- "integration": None,
- }
-
- batch_export_data: dict[str, t.Any] = {
- "name": "my-production-s3-bucket-destination",
- "destination": destination_data,
- "interval": interval,
- }
- client.force_login(user)
-
- with override_settings(TEST=0, DEBUG=0):
- response = create_batch_export(
- client,
- team.pk,
- batch_export_data,
- )
-
- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
- assert f"Invalid endpoint_url: '{endpoint_url}'" in response.json()["detail"]
-
-
@pytest.mark.parametrize(
"host",
[
diff --git a/posthog/api/test/batch_exports/test_create_azure_blob.py b/posthog/api/test/batch_exports/test_create_azure_blob.py
new file mode 100644
index 000000000000..6415632c3427
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_create_azure_blob.py
@@ -0,0 +1,72 @@
+import pytest
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+from temporalio.client import ScheduleActionStartWorkflow
+
+from posthog.api.test.batch_exports.conftest import describe_schedule
+from posthog.api.test.batch_exports.operations import create_batch_export
+from posthog.models.integration import Integration
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
+def azure_blob_integration(team, user):
+ """Create an Azure Blob integration."""
+ return Integration.objects.create(
+ team=team,
+ kind=Integration.IntegrationKind.AZURE_BLOB,
+ integration_id="my-storage-account",
+ config={},
+ sensitive_config={
+ "connection_string": "DefaultEndpointsProtocol=https;AccountName=my-storage-account;AccountKey=my-key;EndpointSuffix=core.windows.net"
+ },
+ created_by=user,
+ )
+
+
+def test_creating_azure_blob_batch_export_using_integration(
+ client: HttpClient, temporal, organization, team, user, azure_blob_integration
+):
+ """Test that we can create an Azure Blob batch export using an integration."""
+ destination_data = {
+ "type": "AzureBlob",
+ "config": {
+ "container_name": "test-container",
+ "prefix": "test-prefix/",
+ },
+ "integration": azure_blob_integration.id,
+ }
+
+ batch_export_data = {
+ "name": "my-azure-blob-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+
+ data = response.json()
+ assert data["destination"]["type"] == "AzureBlob"
+ assert data["destination"]["config"]["container_name"] == "test-container"
+ assert data["destination"]["config"]["prefix"] == "test-prefix/"
+ assert data["interval"] == "hour"
+
+ temporal_schedule = describe_schedule(temporal, data["id"])
+ assert temporal_schedule is not None
+ assert temporal_schedule.schedule is not None
+ assert isinstance(temporal_schedule.schedule.action, ScheduleActionStartWorkflow)
+ assert temporal_schedule.schedule.action.workflow == "azure-blob-export"
diff --git a/posthog/api/test/batch_exports/test_create_databricks.py b/posthog/api/test/batch_exports/test_create_databricks.py
new file mode 100644
index 000000000000..3e29e33d4086
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_create_databricks.py
@@ -0,0 +1,254 @@
+import datetime as dt
+
+import pytest
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+from temporalio.client import ScheduleActionStartWorkflow
+
+from posthog.api.test.batch_exports.conftest import describe_schedule
+from posthog.api.test.batch_exports.operations import create_batch_export
+from posthog.models.integration import Integration
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
+def databricks_integration(team, user):
+ """Create a Databricks integration."""
+ return Integration.objects.create(
+ team=team,
+ kind=Integration.IntegrationKind.DATABRICKS,
+ integration_id="my-server-hostname",
+ config={"server_hostname": "my-server-hostname"},
+ sensitive_config={"client_id": "my-client-id", "client_secret": "my-client-secret"},
+ created_by=user,
+ )
+
+
+def test_creating_databricks_batch_export_using_integration(
+ client: HttpClient, temporal, organization, team, user, databricks_integration
+):
+ """Test that we can create a Databricks batch export using an integration.
+
+ Using integrations is the preferred way to handle credentials for batch exports going forward.
+ """
+
+ destination_data = {
+ "type": "Databricks",
+ "config": {
+ "http_path": "my-http-path",
+ "catalog": "my-catalog",
+ "schema": "my-schema",
+ "table_name": "my-table-name",
+ },
+ "integration": databricks_integration.id,
+ }
+
+ batch_export_data = {
+ "name": "my-databricks-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+
+ data = response.json()
+ assert data["destination"] == destination_data
+
+ schedule = describe_schedule(temporal, data["id"])
+ intervals = schedule.schedule.spec.intervals
+
+ assert len(intervals) == 1
+ assert schedule.schedule.spec.intervals[0].every == dt.timedelta(hours=1)
+ assert isinstance(schedule.schedule.action, ScheduleActionStartWorkflow)
+ assert schedule.schedule.action.workflow == "databricks-export"
+
+
+def test_creating_databricks_batch_export_fails_if_integration_is_missing(
+ client: HttpClient, temporal, organization, team, user
+):
+ """Test that creating a Databricks batch export fails if the integration is missing.
+
+ Using integrations is the preferred way to handle credentials for batch exports going forward.
+ """
+
+ destination_data = {
+ "type": "Databricks",
+ "config": {
+ "http_path": "my-http-path",
+ "catalog": "my-catalog",
+ "schema": "my-schema",
+ "table_name": "my-table-name",
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-databricks-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
+
+ assert response.json() == {
+ "type": "validation_error",
+ "code": "invalid_input",
+ "detail": "Integration is required for Databricks batch exports",
+ "attr": "destination",
+ }
+
+
+def test_creating_databricks_batch_export_fails_if_integration_is_invalid(
+ client: HttpClient, temporal, organization, team, user
+):
+ """Test that creating a Databricks batch export fails if the integration is invalid.
+
+ Using integrations is the preferred way to handle credentials for batch exports going forward.
+
+ In this case, the integration is missing the client_secret. In theory, this shouldn't happen, as we validate the
+ integration when creating it via the API.
+ """
+
+ integration = Integration.objects.create(
+ team=team,
+ kind=Integration.IntegrationKind.DATABRICKS,
+ integration_id="my-server-hostname",
+ config={"server_hostname": "my-server-hostname"},
+ sensitive_config={"client_id": "my-client-id"},
+ created_by=user,
+ )
+
+ destination_data = {
+ "type": "Databricks",
+ "config": {
+ "http_path": "my-http-path",
+ "catalog": "my-catalog",
+ "schema": "my-schema",
+ "table_name": "my-table-name",
+ },
+ "integration": integration.pk,
+ }
+
+ batch_export_data = {
+ "name": "my-databricks-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
+ assert response.json()["detail"] == "Databricks integration is not valid: 'client_secret' missing"
+
+
+def test_creating_databricks_batch_export_fails_if_integration_does_not_exist(
+ client: HttpClient,
+ temporal,
+ organization,
+ team,
+ user,
+):
+ """Test that creating a Databricks batch export fails if the integration does not exist in the database.
+
+ Using integrations is the preferred way to handle credentials for batch exports going forward.
+ """
+
+ destination_data = {
+ "type": "Databricks",
+ "config": {
+ "http_path": "my-http-path",
+ "catalog": "my-catalog",
+ "schema": "my-schema",
+ "table_name": "my-table-name",
+ },
+ "integration": 999,
+ }
+
+ batch_export_data = {
+ "name": "my-databricks-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
+
+ assert response.json() == {
+ "type": "validation_error",
+ "code": "does_not_exist",
+ "detail": 'Invalid pk "999" - object does not exist.',
+ "attr": "destination__integration",
+ }
+
+
+def test_creating_databricks_batch_export_fails_if_integration_is_not_the_correct_type(
+ client: HttpClient, temporal, organization, team, user
+):
+ """Test that creating a Databricks batch export fails if the integration is not the correct type.
+
+ Using integrations is the preferred way to handle credentials for batch exports going forward.
+
+ In this case, the integration is not a Databricks integration.
+ """
+
+ integration = Integration.objects.create(
+ team=team,
+ kind=Integration.IntegrationKind.SLACK,
+ integration_id="my-server-hostname",
+ config={"server_hostname": "my-server-hostname"},
+ sensitive_config={"client_id": "my-client-id"},
+ created_by=user,
+ )
+
+ destination_data = {
+ "type": "Databricks",
+ "config": {
+ "http_path": "my-http-path",
+ "catalog": "my-catalog",
+ "schema": "my-schema",
+ "table_name": "my-table-name",
+ },
+ "integration": integration.pk,
+ }
+
+ batch_export_data = {
+ "name": "my-databricks-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
+ assert response.json()["detail"] == "Integration is not a Databricks integration."
diff --git a/posthog/api/test/batch_exports/test_create_http.py b/posthog/api/test/batch_exports/test_create_http.py
new file mode 100644
index 000000000000..45143bbcaee8
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_create_http.py
@@ -0,0 +1,55 @@
+import pytest
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+
+from posthog.api.test.batch_exports.operations import create_batch_export
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
+ "model,expected_status,expected_error",
+ [
+ ("events", status.HTTP_201_CREATED, None),
+ (None, status.HTTP_201_CREATED, None),
+ ("persons", status.HTTP_400_BAD_REQUEST, "HTTP batch exports only support the events model"),
+ ],
+)
+def test_creating_http_batch_export_only_allows_events_model(
+ client: HttpClient, temporal, organization, team, user, model, expected_status, expected_error
+):
+ """HTTP batch exports are used for migrations, and therefore only support the events model."""
+
+ destination_data = {
+ "type": "HTTP",
+ "config": {
+ "url": "https://us.i.posthog.com/batch/",
+ "token": "secret-token",
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-http-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ if model is not None:
+ batch_export_data["model"] = model
+
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ assert response.status_code == expected_status, response.json()
+
+ if expected_error:
+ assert response.json()["detail"] == expected_error
diff --git a/posthog/api/test/batch_exports/test_create_redshift.py b/posthog/api/test/batch_exports/test_create_redshift.py
new file mode 100644
index 000000000000..62ce3b59501c
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_create_redshift.py
@@ -0,0 +1,158 @@
+import pytest
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+
+from posthog.api.test.batch_exports.operations import create_batch_export
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
+ "mode,copy_inputs,expected_status",
+ [
+ (
+ "INSERT",
+ {},
+ status.HTTP_201_CREATED,
+ ),
+ (
+ "INSERT",
+ None,
+ status.HTTP_201_CREATED,
+ ),
+ (
+ "COPY",
+ {
+ "s3_bucket": "my-production-s3-bucket",
+ "region_name": "us-east-1",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ "authorization": "default",
+ },
+ status.HTTP_201_CREATED,
+ ),
+ (
+ "COPY",
+ {
+ "s3_bucket": "my-production-s3-bucket",
+ "region_name": "us-east-1",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ "authorization": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ },
+ status.HTTP_201_CREATED,
+ ),
+ # Missing required 's3_bucket'
+ (
+ "COPY",
+ {
+ "region_name": "us-east-1",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ "authorization": "default",
+ },
+ status.HTTP_400_BAD_REQUEST,
+ ),
+ # Missing required 'region_name'
+ (
+ "COPY",
+ {
+ "s3_bucket": "my-production-s3-bucket",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ "authorization": "default",
+ },
+ status.HTTP_400_BAD_REQUEST,
+ ),
+ # Missing required 'aws_secret_access_key' in 'bucket_credentials
+ (
+ "COPY",
+ {
+ "s3_bucket": "my-production-s3-bucket",
+ "region_name": "us-east-1",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {"aws_access_key_id": "abc123"},
+ "authorization": "default",
+ },
+ status.HTTP_400_BAD_REQUEST,
+ ),
+ # Empty 'bucket_credentials'
+ (
+ "COPY",
+ {
+ "s3_bucket": "my-production-s3-bucket",
+ "region_name": "us-east-1",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {},
+ "authorization": "default",
+ },
+ status.HTTP_400_BAD_REQUEST,
+ ),
+ # Empty 'authorization'
+ (
+ "COPY",
+ {
+ "s3_bucket": "my-production-s3-bucket",
+ "region_name": "us-east-1",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ "authorization": {},
+ },
+ status.HTTP_400_BAD_REQUEST,
+ ),
+ # Empty 'authorization' as IAMRole
+ (
+ "COPY",
+ {
+ "s3_bucket": "my-production-s3-bucket",
+ "region_name": "us-east-1",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ "authorization": "",
+ },
+ status.HTTP_400_BAD_REQUEST,
+ ),
+ ],
+)
+def test_create_redshift_batch_export_validates_copy_inputs(
+ client: HttpClient, mode, copy_inputs, expected_status, temporal, organization, team, user
+):
+ """Test creating a BatchExport with Redshift destination validates inputs for 'COPY'."""
+
+ destination_data = {
+ "type": "Redshift",
+ "config": {
+ "user": "user",
+ "password": "my-password",
+ "database": "my-db",
+ "host": "localhost",
+ "schema": "public",
+ "table_name": "my_events",
+ "mode": mode,
+ "copy_inputs": copy_inputs,
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-production-redshiftn-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ assert response.status_code == expected_status, response.json()
+
+ if expected_status == status.HTTP_400_BAD_REQUEST:
+ assert "Missing required" in response.json()["detail"]
diff --git a/posthog/api/test/batch_exports/test_create_s3.py b/posthog/api/test/batch_exports/test_create_s3.py
new file mode 100644
index 000000000000..f75b272e5f80
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_create_s3.py
@@ -0,0 +1,288 @@
+import typing as t
+
+import pytest
+
+from django.test import override_settings
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+
+from posthog.api.test.batch_exports.operations import create_batch_export
+from posthog.batch_exports.models import S3_FAMILY_TYPES
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+_S3_FAMILY_BASE_CONFIG = {
+ "bucket_name": "my-bucket",
+ "region": "us-east-1",
+ "prefix": "events/",
+ "aws_access_key_id": "key",
+ "aws_secret_access_key": "secret",
+}
+
+
+ "destination_type,extra_config,expected_persisted_type",
+ [
+ # Legacy `S3` alias is accepted and persisted as-is (no coercion).
+ ("S3", {}, "S3"),
+ ("S3", {"endpoint_url": "https://localhost:9000"}, "S3"),
+ # Refined AwsS3 (with AWS-only encryption field)
+ ("AwsS3", {"encryption": "AES256"}, "AwsS3"),
+ # Refined S3Compatible (endpoint_url is required)
+ ("S3Compatible", {"endpoint_url": "https://localhost:9000"}, "S3Compatible"),
+ ],
+)
+def test_create_s3_family_batch_export(
+ client: HttpClient,
+ temporal,
+ organization,
+ team,
+ user,
+ destination_type,
+ extra_config,
+ expected_persisted_type,
+):
+ """Posting any S3-family destination type creates a batch export and persists with the expected type."""
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ {
+ "name": "my-export",
+ "interval": "hour",
+ "destination": {
+ "type": destination_type,
+ "config": {**_S3_FAMILY_BASE_CONFIG, **extra_config},
+ },
+ },
+ )
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+ assert response.json()["destination"]["type"] == expected_persisted_type
+
+
[email protected]("destination_type", sorted(S3_FAMILY_TYPES))
+def test_create_s3_family_batch_export_validates_empty_inputs(
+ client: HttpClient, temporal, organization, team, user, destination_type
+):
+ """Empty required string inputs are rejected for every S3-family destination."""
+ client.force_login(user)
+ config = {
+ **_S3_FAMILY_BASE_CONFIG,
+ "aws_access_key_id": "",
+ "aws_secret_access_key": "",
+ }
+ if destination_type == "S3Compatible":
+ # S3Compatible additionally requires `endpoint_url` to be present.
+ config["endpoint_url"] = "https://localhost:9000"
+
+ response = create_batch_export(
+ client,
+ team.pk,
+ {
+ "name": "my-export",
+ "interval": "hour",
+ "destination": {"type": destination_type, "config": config},
+ },
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert response.json()["detail"] == "The following inputs are empty: ['aws_access_key_id', 'aws_secret_access_key']"
+
+
+ "destination_type,missing_field",
+ [
+ *((dt, field) for dt in sorted(S3_FAMILY_TYPES) for field in ("aws_access_key_id", "aws_secret_access_key")),
+ # `endpoint_url` is required only for S3Compatible.
+ ("S3Compatible", "endpoint_url"),
+ ],
+)
+def test_create_s3_family_batch_export_validates_missing_required_inputs(
+ client: HttpClient,
+ temporal,
+ organization,
+ team,
+ user,
+ destination_type,
+ missing_field,
+):
+ """Missing required fields are rejected for every S3-family destination."""
+ client.force_login(user)
+ config = {**_S3_FAMILY_BASE_CONFIG}
+ if destination_type == "S3Compatible":
+ # S3Compatible requires `endpoint_url` to be present; include it in the
+ # base so only `missing_field` is missing after the pop below.
+ config["endpoint_url"] = "https://localhost:9000"
+
+ config.pop(missing_field, None)
+
+ response = create_batch_export(
+ client,
+ team.pk,
+ {
+ "name": "my-export",
+ "interval": "hour",
+ "destination": {"type": destination_type, "config": config},
+ },
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
+ assert f"missing required field: '{missing_field}'" in response.json()["detail"]
+
+
+ "destination_type,extra_config,offending_field",
+ [
+ # AwsS3 rejects S3-compatible-only fields.
+ ("AwsS3", {"endpoint_url": "https://localhost:9000"}, "endpoint_url"),
+ ("AwsS3", {"use_virtual_style_addressing": True}, "use_virtual_style_addressing"),
+ # S3Compatible rejects AWS-only fields.
+ ("S3Compatible", {"endpoint_url": "https://localhost:9000", "kms_key_id": "alias/test"}, "kms_key_id"),
+ ("S3Compatible", {"endpoint_url": "https://localhost:9000", "encryption": "aws:kms"}, "encryption"),
+ ],
+)
+def test_create_s3_family_batch_export_rejects_inapplicable_fields(
+ client: HttpClient,
+ temporal,
+ organization,
+ team,
+ user,
+ destination_type,
+ extra_config,
+ offending_field,
+):
+ """Strict per-destination validation rejects fields that don't belong to the destination."""
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ {
+ "name": "my-export",
+ "interval": "hour",
+ "destination": {
+ "type": destination_type,
+ "config": {**_S3_FAMILY_BASE_CONFIG, **extra_config},
+ },
+ },
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert offending_field in response.json()["detail"]
+
+
+ "file_format,compression,expected_error_message",
+ [
+ ("JSONLines", None, None),
+ ("JSONLines", "gzip", None),
+ (
+ "JSONLines",
+ "zstd",
+ "Compression zstd is not supported for file format JSONLines. Supported compressions are ['gzip', 'brotli']",
+ ),
+ ("Parquet", None, None),
+ ("Parquet", "gzip", None),
+ ("Parquet", "brotli", None),
+ ("Parquet", "zstd", None),
+ (
+ "Parquet",
+ "unknown",
+ "Compression unknown is not supported for file format Parquet. Supported compressions are ['zstd', 'lz4', 'snappy', 'gzip', 'brotli']",
+ ),
+ (
+ "unknown",
+ "gzip",
+ "File format unknown is not supported. Supported file formats are ['Parquet', 'JSONLines']",
+ ),
+ ],
+)
+def test_create_s3_batch_export_validates_file_format_and_compression(
+ client: HttpClient, file_format, compression, expected_error_message, temporal, organization, team, user
+):
+ """Test creating a BatchExport with S3 destination validates file format and compression."""
+
+ destination_data = {
+ "type": "S3",
+ "config": {
+ "bucket_name": "my-s3-bucket",
+ "region": "us-east-1",
+ "prefix": "posthog-events/",
+ "aws_access_key_id": "abc123",
+ "aws_secret_access_key": "secret",
+ "file_format": file_format,
+ "compression": compression,
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-s3-bucket",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ if expected_error_message is None:
+ assert response.status_code == status.HTTP_201_CREATED
+ else:
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert response.json()["detail"] == expected_error_message
+
+
+ "destination_type",
+ # Only types that accept `endpoint_url` reach the SSRF check.
+ ["S3", "S3Compatible"],
+)
+ "endpoint_url",
+ [
+ "https://192.168.1.1",
+ "http://127.0.0.1",
+ "http://[::1]/",
+ "http://10.0.0.1:9000/",
+ "http://169.254.0.0:8080/data",
+ "http://localhost",
+ ],
+)
+def test_creating_s3_family_batch_export_fails_if_using_invalid_endpoint_url(
+ client: HttpClient, temporal, organization, team, user, destination_type, endpoint_url
+):
+ """Test that creating an S3 batch export fails if passing an internal IP as endpoint URL.
+
+ Last time I checked, we are not S3.
+ """
+
+ destination_data = {
+ "type": destination_type,
+ "config": {
+ **_S3_FAMILY_BASE_CONFIG,
+ "use_virtual_style_addressing": True,
+ "endpoint_url": endpoint_url,
+ },
+ "integration": None,
+ }
+
+ batch_export_data: dict[str, t.Any] = {
+ "name": "my-export",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+ client.force_login(user)
+
+ with override_settings(TEST=0, DEBUG=0):
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
+ assert f"Invalid endpoint_url: '{endpoint_url}'" in response.json()["detail"]
diff --git a/posthog/api/test/batch_exports/test_create_snowflake.py b/posthog/api/test/batch_exports/test_create_snowflake.py
new file mode 100644
index 000000000000..613ff5197799
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_create_snowflake.py
@@ -0,0 +1,81 @@
+import pytest
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+
+from posthog.api.test.batch_exports.operations import create_batch_export
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
+ "auth_type,credentials,expected_status",
+ [
+ # Password auth type tests
+ (
+ "password",
+ {"password": "abc123"},
+ status.HTTP_201_CREATED,
+ ),
+ (
+ "password",
+ {},
+ status.HTTP_400_BAD_REQUEST,
+ ),
+ # Key pair auth type tests
+ (
+ "keypair",
+ {"private_key": "SECRET_KEY"},
+ status.HTTP_201_CREATED,
+ ),
+ (
+ "keypair",
+ {},
+ status.HTTP_400_BAD_REQUEST,
+ ),
+ ],
+)
+def test_create_snowflake_batch_export_validates_credentials(
+ client: HttpClient, auth_type, credentials, expected_status, temporal, organization, team, user
+):
+ """Test creating a BatchExport with Snowflake destination validates credentials based on auth type."""
+
+ destination_data = {
+ "type": "Snowflake",
+ "config": {
+ "account": "my-account",
+ "user": "user",
+ "database": "my-db",
+ "warehouse": "COMPUTE_WH",
+ "schema": "public",
+ "table_name": "my_events",
+ "authentication_type": auth_type,
+ **credentials,
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-production-snowflake-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ assert response.status_code == expected_status
+
+ if expected_status == status.HTTP_400_BAD_REQUEST:
+ if auth_type == "password":
+ assert "Password is required if authentication type is password" in response.json()["detail"]
+ else:
+ assert "Private key is required if authentication type is key pair" in response.json()["detail"]
diff --git a/posthog/api/test/batch_exports/test_create_workflows.py b/posthog/api/test/batch_exports/test_create_workflows.py
new file mode 100644
index 000000000000..955611101666
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_create_workflows.py
@@ -0,0 +1,101 @@
+import pytest
+from unittest import mock
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+
+from posthog.api.test.batch_exports.conftest import assert_is_daily_schedule, describe_schedule
+from posthog.api.test.batch_exports.operations import create_batch_export
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
+def enable_backfilling_workflows(team):
+ with mock.patch(
+ "posthog.batch_exports.http.posthoganalytics.feature_enabled", return_value=True
+ ) as feature_enabled:
+ yield
+
+ feature_enabled.assert_any_call(
+ "backfill-workflows-destination",
+ str(team.uuid),
+ groups={"organization": str(team.organization.id)},
+ group_properties={
+ "organization": {
+ "id": str(team.organization.id),
+ "created_at": team.organization.created_at,
+ }
+ },
+ send_feature_flag_events=False,
+ )
+
+
+def test_creating_workflows_batch_export(
+ client: HttpClient, temporal, organization, team, user, enable_backfilling_workflows
+):
+ """Test that we can create a Workflows batch export if the feature flag is enabled."""
+
+ destination_data = {
+ "type": "Workflows",
+ "config": {
+ "hog_function_id": "aaaa-bbbb-cccc",
+ },
+ "integration": None,
+ }
+
+ batch_export_data = {
+ "name": "my-workflows-destination",
+ "destination": destination_data,
+ "interval": "day",
+ }
+
+ client.force_login(user)
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+
+ data = response.json()
+ assert data["destination"] == destination_data
+
+ schedule = describe_schedule(temporal, data["id"])
+ assert_is_daily_schedule(schedule, 0)
+
+
+def test_creating_workflows_batch_export_fails_if_feature_flag_is_not_enabled(
+ client: HttpClient, temporal, organization, team, user
+):
+ """Test that creating a Workflows batch export fails if the feature flag is not enabled."""
+
+ destination_data = {
+ "type": "Workflows",
+ "config": {
+ "hog_function_id": "aaaa-bbbb-cccc",
+ },
+ "integration": None,
+ }
+
+ batch_export_data = {
+ "name": "my-workflows-destination",
+ "destination": destination_data,
+ "interval": "day",
+ }
+
+ client.force_login(user)
+
+ response = create_batch_export(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN, response.json()
+ assert "Backfilling Workflows is not enabled for this team." in response.json()["detail"]
diff --git a/posthog/api/test/batch_exports/test_list.py b/posthog/api/test/batch_exports/test_list.py
index 4cf1a613eb3a..0b9b92828269 100644
--- a/posthog/api/test/batch_exports/test_list.py
+++ b/posthog/api/test/batch_exports/test_list.py
@@ -159,7 +159,7 @@ def test_list_filters_workflows_destination(client: HttpClient, organization, te
client.force_login(user)
s3_destination_data = {
- "type": "S3",
+ "type": "AwsS3",
"config": {
"bucket_name": "my-production-s3-bucket",
"region": "us-east-1",
@@ -193,4 +193,4 @@ def test_list_filters_workflows_destination(client: HttpClient, organization, te
response = list_batch_exports_ok(client, team.pk)
assert len(response["results"]) == 1
- assert response["results"][0]["destination"]["type"] == "S3"
+ assert response["results"][0]["destination"]["type"] == "AwsS3"
diff --git a/posthog/api/test/batch_exports/test_test.py b/posthog/api/test/batch_exports/test_test.py
index fc1224536322..9a7b808df271 100644
--- a/posthog/api/test/batch_exports/test_test.py
+++ b/posthog/api/test/batch_exports/test_test.py
@@ -174,6 +174,56 @@ def test_can_run_s3_test_step_for_destination(
assert destination_test["result"]["message"] is None
+def test_run_test_step_rejects_destination_type_change(client: HttpClient, temporal, organization, team, user):
+ """A test step must not be able to change the destination type of an existing export.
+
+ Otherwise a caller could, for example, switch an "AwsS3" export (no `endpoint_url`) to the
+ legacy "S3" type, supply a `endpoint_url` they control, and have the stored credentials tested
+ against that endpoint.
+ """
+
+ destination_data = {
+ "type": "AwsS3",
+ "config": {
+ "bucket_name": "my-production-s3-bucket",
+ "region": "us-east-1",
+ "prefix": "posthog-events/",
+ "aws_access_key_id": "abc123",
+ "aws_secret_access_key": "secret",
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-production-s3-bucket-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+ batch_export = create_batch_export_ok(client, team.pk, batch_export_data)
+
+ malicious_data = {
+ "name": "my-production-s3-bucket-destination",
+ "destination": {
+ "type": "S3",
+ "config": {"endpoint_url": "https://attacker.example"},
+ },
+ "interval": "hour",
+ }
+
+ with unittest.mock.patch("posthog.batch_exports.http.get_destination_test") as mock_get_destination_test:
+ response = client.post(
+ f"/api/projects/{team.pk}/batch_exports/{batch_export['id']}/run_test_step",
+ {**{"step": 0}, **malicious_data},
+ content_type="application/json",
+ )
+
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
+ assert "Cannot change destination type" in response.json()["detail"]
+ # Validation must fail before any destination test (and therefore any outbound request) runs.
+ mock_get_destination_test.assert_not_called()
+
+
@pytest.fixture
def database():
"""Generate a unique database name for tests."""
diff --git a/posthog/api/test/batch_exports/test_update.py b/posthog/api/test/batch_exports/test_update.py
index 636f9c2916b0..75f590ee2590 100644
--- a/posthog/api/test/batch_exports/test_update.py
+++ b/posthog/api/test/batch_exports/test_update.py
@@ -544,7 +544,7 @@ def test_can_patch_config_with_invalid_old_values(client: HttpClient, interval,
assert args.get("invalid_key", None) is None
-def test_patch_different_type_resets_config(
+def test_patch_rejects_destination_type_change(
client: HttpClient,
temporal,
organization,
@@ -552,13 +552,9 @@ def test_patch_different_type_resets_config(
user,
bigquery_integration,
):
- """Assert patching a config with a different type resets it.
-
- We confirm no previous values are present in Temporal or in the database.
- """
- interval = "hour"
+ """Assert PATCH cannot change the destination type — callers must delete and recreate."""
destination_data = {
- "type": "S3",
+ "type": "AwsS3",
"config": {
"bucket_name": "my-production-s3-bucket",
"region": "us-east-1",
@@ -570,18 +566,12 @@ def test_patch_different_type_resets_config(
batch_export_data = {
"name": "my-production-s3-bucket-destination",
- "interval": interval,
+ "destination": destination_data,
+ "interval": "hour",
}
client.force_login(user)
-
- destination = BatchExportDestination(**destination_data)
- batch_export = BatchExport(team=team, destination=destination, **batch_export_data)
-
- sync_batch_export(batch_export, created=True)
-
- destination.save()
- batch_export.save()
+ batch_export = create_batch_export_ok(client, team.pk, batch_export_data)
new_destination_data = {
"type": "BigQuery",
@@ -591,32 +581,69 @@ def test_patch_different_type_resets_config(
"dataset_id": "test",
},
}
+ response = patch_batch_export(
+ client,
+ team.pk,
+ batch_export["id"],
+ {"destination": new_destination_data},
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "Cannot change destination type" in response.json()["detail"]
- new_batch_export_data = {
- "name": "my-production-bigquery-destination",
- "destination": new_destination_data,
+ # The original destination is still intact.
+ refreshed = get_batch_export_ok(client, team.pk, batch_export["id"])
+ assert refreshed["destination"]["type"] == "AwsS3"
+ assert refreshed["destination"]["config"]["bucket_name"] == "my-production-s3-bucket"
+
+
+def test_put_rejects_destination_type_change(
+ client: HttpClient,
+ temporal,
+ organization,
+ team,
+ user,
+):
+ """Assert PUT cannot change the destination type either — same restriction as PATCH."""
+ destination_data = {
+ "type": "AwsS3",
+ "config": {
+ "bucket_name": "my-production-s3-bucket",
+ "region": "us-east-1",
+ "prefix": "posthog-events/",
+ "aws_access_key_id": "abc123",
+ "aws_secret_access_key": "secret",
+ },
}
- response = patch_batch_export(client, team.pk, batch_export.id, new_batch_export_data)
- assert response.status_code == status.HTTP_200_OK, response.json()
+ batch_export_data = {
+ "name": "my-production-s3-bucket-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
- batch_export_data = get_batch_export_ok(client, team.pk, batch_export.id)
- assert batch_export_data["interval"] == interval
- assert batch_export_data["destination"]["config"].get("bucket_name") is None
- assert batch_export_data["destination"]["config"].get("aws_secret_access_key") is None
- assert batch_export_data["destination"]["config"]["dataset_id"] == "test"
- assert batch_export_data["destination"]["config"]["table_id"] == "test"
- assert batch_export_data["destination"]["integration"] == bigquery_integration.id
+ client.force_login(user)
+ batch_export = create_batch_export_ok(client, team.pk, batch_export_data)
- # validate the underlying temporal schedule has been updated
- codec = EncryptionCodec(settings=settings)
- new_schedule = describe_schedule(temporal, batch_export_data["id"])
- decoded_payload = async_to_sync(codec.decode)(new_schedule.schedule.action.args)
- args = json.loads(decoded_payload[0].data)
- assert args["table_id"] == "test"
- assert args.get("aws_access_key_id") is None
- assert args.get("bucket_name") is None
- assert args.get("aws_secret_access_key") is None
+ new_batch_export_data = {
+ "name": "my-production-s3-bucket-destination",
+ "destination": {
+ "type": "BigQuery",
+ "config": {
+ "table_id": "test",
+ "dataset_id": "test",
+ "project_id": "test",
+ },
+ },
+ "interval": "hour",
+ }
+ response = put_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "Cannot change destination type" in response.json()["detail"]
+
+ # The original destination is still intact.
+ refreshed = get_batch_export_ok(client, team.pk, batch_export["id"])
+ assert refreshed["destination"]["type"] == "AwsS3"
+ assert refreshed["destination"]["config"]["bucket_name"] == "my-production-s3-bucket"
def test_can_patch_hogql_query(client: HttpClient, temporal, organization, team, user):
@@ -746,136 +773,6 @@ def test_patch_returns_error_on_unsupported_hogql_query(client: HttpClient, temp
assert response.status_code == status.HTTP_400_BAD_REQUEST
-def test_can_patch_snowflake_batch_export_credentials(client: HttpClient, temporal, organization, team, user):
- """Test we can switch Snowflake authentication types while preserving credentials."""
- destination_data = {
- "type": "Snowflake",
- "config": {
- "account": "my-account",
- "user": "user",
- "password": "password123",
- "database": "my-db",
- "warehouse": "COMPUTE_WH",
- "schema": "public",
- "table_name": "my_events",
- "authentication_type": "password",
- },
- }
-
- batch_export_data = {
- "name": "my-snowflake-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- batch_export = create_batch_export_ok(
- client,
- team.pk,
- batch_export_data,
- )
-
- # Test switching to key pair auth type
- new_destination_data = {
- "type": "Snowflake",
- "config": {
- "authentication_type": "keypair",
- "private_key": "SECRET_KEY",
- },
- }
-
- new_batch_export_data = {
- "destination": new_destination_data,
- }
-
- response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
- assert response.status_code == status.HTTP_200_OK, response.json()
-
- # Verify the auth type switch worked and other fields were preserved
- batch_export = get_batch_export_ok(client, team.pk, batch_export["id"])
- assert batch_export["destination"]["type"] == "Snowflake"
- assert batch_export["destination"]["config"]["account"] == "my-account"
- assert batch_export["destination"]["config"]["authentication_type"] == "keypair"
- assert "private_key" not in batch_export["destination"]["config"] # Private key should be hidden in response
-
- # Test switching back to password auth type without providing password (should keep original)
- new_destination_data = {
- "type": "Snowflake",
- "config": {
- "authentication_type": "password",
- },
- }
-
- new_batch_export_data = {
- "destination": new_destination_data,
- }
-
- response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
- assert response.status_code == status.HTTP_200_OK, response.json()
-
- # Verify switched back to password auth and kept original password
- batch_export = get_batch_export_ok(client, team.pk, batch_export["id"])
- assert batch_export["destination"]["type"] == "Snowflake"
- assert batch_export["destination"]["config"]["account"] == "my-account"
- assert batch_export["destination"]["config"]["authentication_type"] == "password"
- assert "password" not in batch_export["destination"]["config"] # Password should be hidden in response
-
-
-def test_switching_snowflake_auth_type_to_keypair_requires_private_key(
- client: HttpClient, temporal, organization, team, user
-):
- """Test that switching to keypair authentication requires a private key to be provided."""
- destination_data = {
- "type": "Snowflake",
- "config": {
- "account": "my-account",
- "user": "user",
- "password": "password123",
- "database": "my-db",
- "warehouse": "COMPUTE_WH",
- "schema": "public",
- "table_name": "my_events",
- "authentication_type": "password",
- },
- }
-
- batch_export_data = {
- "name": "my-snowflake-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- batch_export = create_batch_export_ok(
- client,
- team.pk,
- batch_export_data,
- )
-
- # Test switching to keypair auth type without providing a private key
- new_destination_data = {
- "type": "Snowflake",
- "config": {
- "authentication_type": "keypair",
- },
- }
-
- new_batch_export_data = {
- "destination": new_destination_data,
- }
-
- response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
- assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert "Private key is required if authentication type is key pair" in response.json()["detail"]
-
- # Verify the auth type was not changed
- batch_export = get_batch_export_ok(client, team.pk, batch_export["id"])
- assert batch_export["destination"]["type"] == "Snowflake"
- assert batch_export["destination"]["config"]["authentication_type"] == "password"
-
-
@pytest.fixture
def databricks_integration(team, user):
"""Create a Databricks integration."""
@@ -1025,107 +922,3 @@ def test_can_update_batch_export_with_integration_to_none(
response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
assert response.status_code == status.HTTP_400_BAD_REQUEST
assert "Integration is required for Databricks batch exports" in response.json()["detail"]
-
-
-def test_can_patch_redshift_batch_export(client: HttpClient, temporal, organization, team, user):
- """Test we can patch a Redshift batch export preserving credentials."""
- destination_data = {
- "type": "Redshift",
- "config": {
- "user": "user",
- "password": "my-password",
- "database": "my-db",
- "host": "localhost",
- "schema": "public",
- "table_name": "my_events",
- "mode": "COPY",
- "copy_inputs": {
- "s3_bucket": "my-production-s3-bucket",
- "region_name": "us-east-1",
- "s3_key_prefix": "posthog-events/",
- "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- "authorization": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
- },
- },
- }
-
- batch_export_data = {
- "name": "my-production-redshiftn-destination",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- batch_export = create_batch_export_ok(
- client,
- team.pk,
- batch_export_data,
- )
-
- # Updates bucket name, leaves everything else untouched.
- new_destination_data = {
- "type": "Redshift",
- "config": {
- "copy_inputs": {
- "s3_bucket": "my-new-production-s3-bucket",
- },
- },
- }
-
- new_batch_export_data = {
- "destination": new_destination_data,
- }
-
- response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
- assert response.status_code == status.HTTP_200_OK, response.json()
-
- # Verify the bucket name update worked
- batch_export = get_batch_export_ok(client, team.pk, batch_export["id"])
- assert batch_export["destination"]["type"] == "Redshift"
- assert batch_export["destination"]["config"]["copy_inputs"]["s3_bucket"] == "my-new-production-s3-bucket"
-
-
-def test_updating_s3_batch_export_validates_missing_inputs(client: HttpClient, temporal, organization, team, user):
- """Test updating a BatchExport with S3 destination validates that expected inputs are not empty."""
-
- destination_data = {
- "type": "S3",
- "config": {
- "bucket_name": "my-s3-bucket",
- "region": "us-east-1",
- "prefix": "events/",
- "aws_access_key_id": "abc123",
- "aws_secret_access_key": "secret",
- "file_format": "JSONLines",
- "compression": "gzip",
- },
- }
-
- batch_export_data = {
- "name": "my-s3-bucket",
- "destination": destination_data,
- "interval": "hour",
- }
-
- client.force_login(user)
-
- batch_export = create_batch_export_ok(client, team.pk, batch_export_data)
-
- response = patch_batch_export(
- client,
- team.pk,
- batch_export["id"],
- {
- "destination": {
- "type": "S3",
- "config": {
- "bucket_name": "my-new-bucket",
- "aws_access_key_id": "",
- "aws_secret_access_key": "",
- },
- },
- },
- )
- assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert response.json()["detail"] == "The following inputs are empty: ['aws_access_key_id', 'aws_secret_access_key']"
diff --git a/posthog/api/test/batch_exports/test_update_redshift.py b/posthog/api/test/batch_exports/test_update_redshift.py
new file mode 100644
index 000000000000..15e9af63479d
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_update_redshift.py
@@ -0,0 +1,71 @@
+import pytest
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+
+from posthog.api.test.batch_exports.operations import create_batch_export_ok, get_batch_export_ok, patch_batch_export
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
+def test_can_patch_redshift_batch_export(client: HttpClient, temporal, organization, team, user):
+ """Test we can patch a Redshift batch export preserving credentials."""
+ destination_data = {
+ "type": "Redshift",
+ "config": {
+ "user": "user",
+ "password": "my-password",
+ "database": "my-db",
+ "host": "localhost",
+ "schema": "public",
+ "table_name": "my_events",
+ "mode": "COPY",
+ "copy_inputs": {
+ "s3_bucket": "my-production-s3-bucket",
+ "region_name": "us-east-1",
+ "s3_key_prefix": "posthog-events/",
+ "bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ "authorization": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
+ },
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-production-redshiftn-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+
+ batch_export = create_batch_export_ok(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ # Updates bucket name, leaves everything else untouched.
+ new_destination_data = {
+ "type": "Redshift",
+ "config": {
+ "copy_inputs": {
+ "s3_bucket": "my-new-production-s3-bucket",
+ },
+ },
+ }
+
+ new_batch_export_data = {
+ "destination": new_destination_data,
+ }
+
+ response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
+ assert response.status_code == status.HTTP_200_OK, response.json()
+
+ # Verify the bucket name update worked
+ batch_export = get_batch_export_ok(client, team.pk, batch_export["id"])
+ assert batch_export["destination"]["type"] == "Redshift"
+ assert batch_export["destination"]["config"]["copy_inputs"]["s3_bucket"] == "my-new-production-s3-bucket"
diff --git a/posthog/api/test/batch_exports/test_update_s3.py b/posthog/api/test/batch_exports/test_update_s3.py
new file mode 100644
index 000000000000..819fd442e3ac
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_update_s3.py
@@ -0,0 +1,61 @@
+import pytest
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+
+from posthog.api.test.batch_exports.operations import create_batch_export_ok, patch_batch_export
+from posthog.batch_exports.models import S3_FAMILY_TYPES
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
[email protected]("destination_type", sorted(S3_FAMILY_TYPES))
+def test_updating_s3_family_batch_export_validates_empty_inputs(
+ client: HttpClient, temporal, organization, team, user, destination_type
+):
+ """Empty required string inputs are rejected when patching every S3-family destination."""
+ initial_config = {
+ "bucket_name": "my-s3-bucket",
+ "region": "us-east-1",
+ "prefix": "events/",
+ "aws_access_key_id": "abc123",
+ "aws_secret_access_key": "secret",
+ "file_format": "JSONLines",
+ "compression": "gzip",
+ }
+ if destination_type == "S3Compatible":
+ # S3Compatible additionally requires `endpoint_url` to be present.
+ initial_config["endpoint_url"] = "https://localhost:9000"
+
+ client.force_login(user)
+ batch_export = create_batch_export_ok(
+ client,
+ team.pk,
+ {
+ "name": "my-s3-bucket",
+ "destination": {"type": destination_type, "config": initial_config},
+ "interval": "hour",
+ },
+ )
+
+ response = patch_batch_export(
+ client,
+ team.pk,
+ batch_export["id"],
+ {
+ "destination": {
+ "type": destination_type,
+ "config": {
+ "bucket_name": "my-new-bucket",
+ "aws_access_key_id": "",
+ "aws_secret_access_key": "",
+ },
+ },
+ },
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert response.json()["detail"] == "The following inputs are empty: ['aws_access_key_id', 'aws_secret_access_key']"
diff --git a/posthog/api/test/batch_exports/test_update_snowflake.py b/posthog/api/test/batch_exports/test_update_snowflake.py
new file mode 100644
index 000000000000..59e43691139f
--- /dev/null
+++ b/posthog/api/test/batch_exports/test_update_snowflake.py
@@ -0,0 +1,142 @@
+import pytest
+
+from django.test.client import Client as HttpClient
+
+from rest_framework import status
+
+from posthog.api.test.batch_exports.operations import create_batch_export_ok, get_batch_export_ok, patch_batch_export
+
+pytestmark = [
+ pytest.mark.django_db,
+ pytest.mark.usefixtures("temporal_worker", "cleanup"),
+]
+
+
+def test_can_patch_snowflake_batch_export_credentials(client: HttpClient, temporal, organization, team, user):
+ """Test we can switch Snowflake authentication types while preserving credentials."""
+ destination_data = {
+ "type": "Snowflake",
+ "config": {
+ "account": "my-account",
+ "user": "user",
+ "password": "password123",
+ "database": "my-db",
+ "warehouse": "COMPUTE_WH",
+ "schema": "public",
+ "table_name": "my_events",
+ "authentication_type": "password",
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-snowflake-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+
+ batch_export = create_batch_export_ok(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ # Test switching to key pair auth type
+ new_destination_data = {
+ "type": "Snowflake",
+ "config": {
+ "authentication_type": "keypair",
+ "private_key": "SECRET_KEY",
+ },
+ }
+
+ new_batch_export_data = {
+ "destination": new_destination_data,
+ }
+
+ response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
+ assert response.status_code == status.HTTP_200_OK, response.json()
+
+ # Verify the auth type switch worked and other fields were preserved
+ batch_export = get_batch_export_ok(client, team.pk, batch_export["id"])
+ assert batch_export["destination"]["type"] == "Snowflake"
+ assert batch_export["destination"]["config"]["account"] == "my-account"
+ assert batch_export["destination"]["config"]["authentication_type"] == "keypair"
+ assert "private_key" not in batch_export["destination"]["config"] # Private key should be hidden in response
+
+ # Test switching back to password auth type without providing password (should keep original)
+ new_destination_data = {
+ "type": "Snowflake",
+ "config": {
+ "authentication_type": "password",
+ },
+ }
+
+ new_batch_export_data = {
+ "destination": new_destination_data,
+ }
+
+ response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
+ assert response.status_code == status.HTTP_200_OK, response.json()
+
+ # Verify switched back to password auth and kept original password
+ batch_export = get_batch_export_ok(client, team.pk, batch_export["id"])
+ assert batch_export["destination"]["type"] == "Snowflake"
+ assert batch_export["destination"]["config"]["account"] == "my-account"
+ assert batch_export["destination"]["config"]["authentication_type"] == "password"
+ assert "password" not in batch_export["destination"]["config"] # Password should be hidden in response
+
+
+def test_switching_snowflake_auth_type_to_keypair_requires_private_key(
+ client: HttpClient, temporal, organization, team, user
+):
+ """Test that switching to keypair authentication requires a private key to be provided."""
+ destination_data = {
+ "type": "Snowflake",
+ "config": {
+ "account": "my-account",
+ "user": "user",
+ "password": "password123",
+ "database": "my-db",
+ "warehouse": "COMPUTE_WH",
+ "schema": "public",
+ "table_name": "my_events",
+ "authentication_type": "password",
+ },
+ }
+
+ batch_export_data = {
+ "name": "my-snowflake-destination",
+ "destination": destination_data,
+ "interval": "hour",
+ }
+
+ client.force_login(user)
+
+ batch_export = create_batch_export_ok(
+ client,
+ team.pk,
+ batch_export_data,
+ )
+
+ # Test switching to keypair auth type without providing a private key
+ new_destination_data = {
+ "type": "Snowflake",
+ "config": {
+ "authentication_type": "keypair",
+ },
+ }
+
+ new_batch_export_data = {
+ "destination": new_destination_data,
+ }
+
+ response = patch_batch_export(client, team.pk, batch_export["id"], new_batch_export_data)
+ assert response.status_code == status.HTTP_400_BAD_REQUEST
+ assert "Private key is required if authentication type is key pair" in response.json()["detail"]
+
+ # Verify the auth type was not changed
+ batch_export = get_batch_export_ok(client, team.pk, batch_export["id"])
+ assert batch_export["destination"]["type"] == "Snowflake"
+ assert batch_export["destination"]["config"]["authentication_type"] == "password"
diff --git a/posthog/batch_exports/http.py b/posthog/batch_exports/http.py
index fa5610536fd9..0ece941a6f95 100644
--- a/posthog/batch_exports/http.py
+++ b/posthog/batch_exports/http.py
@@ -35,7 +35,7 @@ from posthog.api.log_entries import LogEntryMixin
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.scoped_related_fields import TeamScopedPrimaryKeyRelatedField
from posthog.api.utils import action
-from posthog.batch_exports.models import BATCH_EXPORT_INTERVALS, TIMEZONES
+from posthog.batch_exports.models import BATCH_EXPORT_INTERVALS, S3_FAMILY_TYPES, TIMEZONES
from posthog.event_usage import groups
from posthog.models import BatchExport, BatchExportBackfill, BatchExportDestination, BatchExportRun, Team, User
from posthog.models.activity_logging.activity_log import ActivityContextBase, Detail, changes_between, log_activity
@@ -490,7 +490,7 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):
export_destination = BatchExportDestination.objects.create(**validated_data)
return export_destination
- def validate(self, data: collections.abc.Mapping[str, typing.Any]) -> collections.abc.Mapping[str, typing.Any]:
+ def validate(self, attrs: collections.abc.Mapping[str, typing.Any]) -> collections.abc.Mapping[str, typing.Any]:
"""Validate the destination configuration based on workflow inputs.
Ensure that the submitted destination configuration passes the following checks:
@@ -501,7 +501,10 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):
Raises:
A `serializers.ValidationError` if any of these checks fail.
"""
- export_type, config = data["type"], data["config"]
+ export_type, config = attrs["type"], attrs["config"]
+ request = self.context.get("request")
+ is_patch = request is not None and request.method == "PATCH"
+
_, workflow_inputs = DESTINATION_WORKFLOWS[export_type]
base_field_names = {field.name for field in dataclasses.fields(BaseBatchExportInputs)}
workflow_fields = dataclasses.fields(workflow_inputs)
@@ -518,8 +521,6 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):
and destination_field.default_factory == dataclasses.MISSING
)
if destination_field.name not in config:
- request = self.context.get("request")
- is_patch = request is not None and request.method == "PATCH"
if is_required and not is_patch:
# When patching we expect a partial configuration. So, we don't
# error on missing required fields.
@@ -547,7 +548,7 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):
config[destination_field.name] = config_value
- return data
+ return attrs
def to_representation(self, instance: BatchExportDestination) -> dict:
data = super().to_representation(instance)
@@ -694,14 +695,18 @@ def resolve_and_validate_url(url: str) -> None:
resolve_and_validate_host(host)
+def is_local_dev_or_test() -> bool:
+ return settings.DEBUG or settings.TEST
+
+
def resolve_and_validate_host(host: str) -> None:
"""Ensure provided host resolves to a non-internal IP."""
- if host == "localhost" and (settings.TEST or settings.DEBUG):
+ if host == "localhost" and is_local_dev_or_test():
return
# Host may already be an IP literal
try:
- if is_ip_internal(host):
+ if is_ip_internal(host) and not is_local_dev_or_test():
raise ValueError("Host resolved to internal IP")
return
except ValueError:
@@ -718,7 +723,7 @@ def resolve_and_validate_host(host: str) -> None:
resolved_ips = {str(r[4][0]) for r in results}
for ip in resolved_ips:
- if is_ip_internal(ip):
+ if is_ip_internal(ip) and not is_local_dev_or_test():
raise ValueError("Host resolved to internal IP")
@@ -927,8 +932,11 @@ class BatchExportSerializer(serializers.ModelSerializer):
existing_config = {}
if instance is not None and destination_type != instance.destination.type:
- # Start fresh if this is changing the batch export type
- existing_config = {}
+ raise serializers.ValidationError(
+ f"Cannot change destination type from '{instance.destination.type}' to '{destination_type}'. "
+ "Delete this batch export and create a new one with the new destination type."
+ )
+
merged_config = recursive_dict_merge(existing_config, config)
# SSRF protection for HTTP batch exports
@@ -943,7 +951,7 @@ class BatchExportSerializer(serializers.ModelSerializer):
if config.get("authentication_type") == "keypair" and merged_config.get("private_key") is None:
raise serializers.ValidationError("Private key is required if authentication type is key pair")
- if destination_type == BatchExportDestination.Destination.S3:
+ if destination_type in S3_FAMILY_TYPES:
# we already validate the required inputs in BatchExportDestinationSerializer::validate
# so here we just ensure that the inputs are not empty
required_non_empty_inputs = (
@@ -1246,11 +1254,8 @@ class BatchExportSerializer(serializers.ModelSerializer):
with transaction.atomic():
if destination_data:
- if destination_data.get("type", batch_export.destination.type) != batch_export.destination.type:
- # Start fresh if this is changing the destination type
- batch_export.destination.config = {}
-
- batch_export.destination.type = destination_data.get("type", batch_export.destination.type)
+ # Type changes are rejected by `validate_destination` — the incoming `type`
+ # (if any) always equals the existing type by the time we get here.
batch_export.destination.config = recursive_dict_merge(
batch_export.destination.config,
destination_data.get("config", {}),
diff --git a/posthog/batch_exports/models.py b/posthog/batch_exports/models.py
index 2baa29716300..6a9cb9c5e5ec 100644
--- a/posthog/batch_exports/models.py
+++ b/posthog/batch_exports/models.py
@@ -24,6 +24,10 @@ 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]
+# All destination types that share the s3-export Temporal workflow.
+# Includes the legacy "S3" alias for backwards compatibility.
+S3_FAMILY_TYPES: frozenset[str] = frozenset({"S3", "AwsS3", "S3Compatible"})
+
class DayOfWeek(IntEnum):
"""Day of the week enum for batch export schedules.
@@ -59,7 +63,9 @@ class BatchExportDestination(UUIDTModel):
class Destination(models.TextChoices):
"""Enumeration of supported destinations for PostHog BatchExports."""
- S3 = "S3"
+ S3 = "S3" # legacy alias; AwsS3 / S3Compatible are the preferred types for new rows
+ AWS_S3 = "AwsS3"
+ S3_COMPATIBLE = "S3Compatible"
SNOWFLAKE = "Snowflake"
POSTGRES = "Postgres"
REDSHIFT = "Redshift"
@@ -73,6 +79,8 @@ class BatchExportDestination(UUIDTModel):
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"},
"Postgres": {"user", "password"},
"Redshift": {"user", "password", "aws_access_key_id", "aws_secret_access_key"},
diff --git a/posthog/migrations/1195_alter_batchexportdestination_type.py b/posthog/migrations/1195_alter_batchexportdestination_type.py
new file mode 100644
index 000000000000..17aa8655d037
--- /dev/null
+++ b/posthog/migrations/1195_alter_batchexportdestination_type.py
@@ -0,0 +1,31 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [("posthog", "1194_project_updated_at")]
+
+ operations = [
+ migrations.AlterField(
+ model_name="batchexportdestination",
+ name="type",
+ field=models.CharField(
+ choices=[
+ ("S3", "S3"),
+ ("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/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index 499806adcbb4..6a59d3d7b27e 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1194_project_updated_at
+1195_alter_batchexportdestination_type
diff --git a/products/batch_exports/backend/api/destination_tests/__init__.py b/products/batch_exports/backend/api/destination_tests/__init__.py
index daed4ea90b11..a512d2df9aa1 100644
--- a/products/batch_exports/backend/api/destination_tests/__init__.py
+++ b/products/batch_exports/backend/api/destination_tests/__init__.py
@@ -1,3 +1,5 @@
+from posthog.batch_exports.models import S3_FAMILY_TYPES
+
from products.batch_exports.backend.api.destination_tests.base import DestinationTest
@@ -10,7 +12,7 @@ def get_destination_test(
(databricks, google-cloud-bigquery, snowflake, etc.). Importing them lazily keeps the
SDKs off the API import path — only the requested destination's SDK loads.
"""
- if destination == "S3":
+ if destination in S3_FAMILY_TYPES:
from products.batch_exports.backend.api.destination_tests.s3 import S3DestinationTest # noqa: PLC0415
return S3DestinationTest()
diff --git a/products/batch_exports/backend/service.py b/products/batch_exports/backend/service.py
index 483e5b041df5..64390b3a1ea1 100644
--- a/products/batch_exports/backend/service.py
+++ b/products/batch_exports/backend/service.py
@@ -250,11 +250,28 @@ 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.
+
Attributes:
bucket_name: The S3 bucket we are exporting to.
region: The AWS region where the bucket is located.
prefix: A prefix for the file name to be created in S3.
+ aws_access_key_id: Access key id used to authenticate with S3.
+ aws_secret_access_key: Secret access key used to authenticate with S3.
+ compression: Compression algorithm to apply to exported files (e.g. "gzip", "brotli"), or None.
+ file_format: File format of exported objects (e.g. "JSONLines", "Parquet"). Defaults to JSONLines.
max_file_size_mb: The maximum file size in MB for each file to be uploaded.
+ encryption: Server-side encryption algorithm to apply (e.g. "AES256", "aws:kms"), or None. AWS-only.
+ kms_key_id: KMS key id to use when `encryption == "aws:kms"`, or None. AWS-only.
+ endpoint_url: Override endpoint for S3-compatible providers (e.g. MinIO, R2). None for AWS.
+ use_virtual_style_addressing: Whether to use virtual-hosted-style
+ addressing rather than path-style. None for AWS.
"""
bucket_name: str
@@ -263,11 +280,48 @@ class S3BatchExportInputs(BaseBatchExportInputs):
aws_access_key_id: str
aws_secret_access_key: str
compression: str | None = None
+ file_format: str = "JSONLines"
+ max_file_size_mb: int | None = None
encryption: str | None = None
kms_key_id: str | None = None
endpoint_url: str | None = None
+ use_virtual_style_addressing: bool = False
+
+
+@dataclass(kw_only=True)
+class S3FamilyBaseInputs(BaseBatchExportInputs):
+ """Shared fields for every S3-family destination.
+
+ Per-destination dataclasses extend this with provider-specific fields.
+ """
+
+ bucket_name: str
+ region: str
+ prefix: str
+ aws_access_key_id: str
+ aws_secret_access_key: str
+ compression: str | None = None
file_format: str = "JSONLines"
max_file_size_mb: int | None = None
+
+
+@dataclass(kw_only=True)
+class AwsS3BatchExportInputs(S3FamilyBaseInputs):
+ """Inputs for an AWS S3 batch export."""
+
+ encryption: str | None = None
+ kms_key_id: str | None = None
+
+
+@dataclass(kw_only=True)
+class S3CompatibleBatchExportInputs(S3FamilyBaseInputs):
+ """Inputs for a non-AWS S3-compatible batch export.
+
+ Covers providers like MinIO, DigitalOcean Spaces, Cloudflare R2, Hetzner, OVH,
+ Backblaze, etc. `endpoint_url` is required.
+ """
+
+ endpoint_url: str
use_virtual_style_addressing: bool = False
@@ -470,6 +524,7 @@ class NoOpInputs(BaseBatchExportInputs):
DESTINATION_WORKFLOWS = {
+ "AwsS3": ("s3-export", AwsS3BatchExportInputs),
"AzureBlob": ("azure-blob-export", AzureBlobBatchExportInputs),
"BigQuery": ("bigquery-export", BigQueryBatchExportInputs),
"Databricks": ("databricks-export", DatabricksBatchExportInputs),
@@ -478,7 +533,10 @@ 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.py
index fd59a65532d3..92992b4150a9 100644
--- a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/s3_batch_export.py
@@ -210,7 +210,13 @@ def s3_default_fields() -> list[BatchExportField]:
@workflow.defn(name="s3-export", failure_exception_types=[workflow.NondeterminismError])
class S3BatchExportWorkflow(PostHogWorkflow):
- """A Temporal Workflow to export ClickHouse data into S3.
+ """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 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 the
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py b/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py
index 8cac4c3b922e..281fa5924b97 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py
@@ -92,7 +92,7 @@ async def minio_client(bucket_name):
@pytest_asyncio.fixture
-async def s3_batch_export(
+async def s3_compatible_batch_export(
ateam,
s3_key_prefix,
bucket_name,
@@ -100,11 +100,10 @@ async def s3_batch_export(
interval,
exclude_events,
temporal_client,
- encryption,
file_format,
):
destination_data = {
- "type": "S3",
+ "type": "S3Compatible",
"config": {
"bucket_name": bucket_name,
"region": "us-east-1",
@@ -114,8 +113,6 @@ async def s3_batch_export(
"endpoint_url": settings.OBJECT_STORAGE_ENDPOINT,
"compression": compression,
"exclude_events": exclude_events,
- "encryption": encryption,
- "kms_key_id": None,
"file_format": file_format,
},
}
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py
index c38b8362abbc..dba5ab8e9ce2 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py
@@ -42,7 +42,9 @@ class RetryableTestException(Exception):
pass
-async def test_s3_export_workflow_handles_unexpected_insert_activity_errors(ateam, s3_batch_export, interval):
+async def test_s3_export_workflow_handles_unexpected_insert_activity_errors(
+ ateam, s3_compatible_batch_export, interval
+):
"""Test S3BatchExport Workflow can handle unexpected errors from executing the insert into S3 activity.
This means we do the right updates to the BatchExportRun model and ensure the workflow fails (since we
@@ -57,10 +59,10 @@ async def test_s3_export_workflow_handles_unexpected_insert_activity_errors(atea
workflow_id = str(uuid.uuid4())
inputs = S3BatchExportInputs(
team_id=ateam.pk,
- batch_export_id=str(s3_batch_export.id),
+ batch_export_id=str(s3_compatible_batch_export.id),
data_interval_end=data_interval_end.isoformat(),
interval=interval,
- **s3_batch_export.destination.config,
+ **s3_compatible_batch_export.destination.config,
)
@activity.defn(name="insert_into_internal_stage_activity")
@@ -93,7 +95,7 @@ async def test_s3_export_workflow_handles_unexpected_insert_activity_errors(atea
retry_policy=RetryPolicy(maximum_attempts=1),
)
- runs = await afetch_batch_export_runs(batch_export_id=s3_batch_export.id)
+ runs = await afetch_batch_export_runs(batch_export_id=s3_compatible_batch_export.id)
assert len(runs) == 1
run = runs[0]
@@ -103,7 +105,9 @@ async def test_s3_export_workflow_handles_unexpected_insert_activity_errors(atea
assert run.bytes_exported is None
-async def test_s3_export_workflow_handles_insert_activity_non_retryable_errors(ateam, s3_batch_export, interval):
+async def test_s3_export_workflow_handles_insert_activity_non_retryable_errors(
+ ateam, s3_compatible_batch_export, interval
+):
"""Test S3BatchExport Workflow can handle non-retryable errors from executing the insert into S3 activity.
This means we do the right updates to the BatchExportRun model and ensure the workflow succeeds (since we
@@ -118,10 +122,10 @@ async def test_s3_export_workflow_handles_insert_activity_non_retryable_errors(a
workflow_id = str(uuid.uuid4())
inputs = S3BatchExportInputs(
team_id=ateam.pk,
- batch_export_id=str(s3_batch_export.id),
+ batch_export_id=str(s3_compatible_batch_export.id),
data_interval_end=data_interval_end.isoformat(),
interval=interval,
- **s3_batch_export.destination.config,
+ **s3_compatible_batch_export.destination.config,
)
class ParamValidationError(Exception):
@@ -156,7 +160,7 @@ async def test_s3_export_workflow_handles_insert_activity_non_retryable_errors(a
retry_policy=RetryPolicy(maximum_attempts=1),
)
- runs = await afetch_batch_export_runs(batch_export_id=s3_batch_export.id)
+ runs = await afetch_batch_export_runs(batch_export_id=s3_compatible_batch_export.id)
assert len(runs) == 1
run = runs[0]
@@ -164,7 +168,7 @@ async def test_s3_export_workflow_handles_insert_activity_non_retryable_errors(a
assert run.latest_error == "ParamValidationError: A useful error message"
-async def test_s3_export_workflow_handles_cancellation(ateam, s3_batch_export, interval):
+async def test_s3_export_workflow_handles_cancellation(ateam, s3_compatible_batch_export, interval):
"""Test that S3 Export Workflow can gracefully handle cancellations when inserting S3 data.
Currently, this only means we do the right updates to the BatchExportRun model.
@@ -174,10 +178,10 @@ async def test_s3_export_workflow_handles_cancellation(ateam, s3_batch_export, i
workflow_id = str(uuid.uuid4())
inputs = S3BatchExportInputs(
team_id=ateam.pk,
- batch_export_id=str(s3_batch_export.id),
+ batch_export_id=str(s3_compatible_batch_export.id),
data_interval_end=data_interval_end.isoformat(),
interval=interval,
- **s3_batch_export.destination.config,
+ **s3_compatible_batch_export.destination.config,
)
@activity.defn(name="insert_into_internal_stage_activity")
@@ -216,7 +220,7 @@ async def test_s3_export_workflow_handles_cancellation(ateam, s3_batch_export, i
with pytest.raises(WorkflowFailureError):
await handle.result()
- runs = await afetch_batch_export_runs(batch_export_id=s3_batch_export.id)
+ runs = await afetch_batch_export_runs(batch_export_id=s3_compatible_batch_export.id)
assert len(runs) == 1
run = runs[0]
@@ -230,7 +234,7 @@ async def test_s3_export_workflow_with_request_timeouts(
minio_client,
bucket_name,
interval,
- s3_batch_export,
+ s3_compatible_batch_export,
s3_key_prefix,
data_interval_end,
data_interval_start,
@@ -275,12 +279,12 @@ async def test_s3_export_workflow_with_request_timeouts(
workflow_id = str(uuid.uuid4())
inputs = S3BatchExportInputs(
team_id=ateam.pk,
- batch_export_id=str(s3_batch_export.id),
+ batch_export_id=str(s3_compatible_batch_export.id),
data_interval_end=data_interval_end.isoformat(),
batch_export_model=batch_export_model,
batch_export_schema=batch_export_schema,
interval=interval,
- **s3_batch_export.destination.config,
+ **s3_compatible_batch_export.destination.config,
)
async with (
@@ -314,7 +318,7 @@ async def test_s3_export_workflow_with_request_timeouts(
execution_timeout=dt.timedelta(minutes=2),
)
- runs = await afetch_batch_export_runs(batch_export_id=s3_batch_export.id)
+ runs = await afetch_batch_export_runs(batch_export_id=s3_compatible_batch_export.id)
assert len(runs) == 2
runs.sort(key=lambda r: r.last_updated_at)
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py
index 7aa3bb4e1c54..80956952fa07 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py
@@ -58,7 +58,7 @@ async def gcs_batch_export(
):
assert bucket_name
destination_data = {
- "type": "S3",
+ "type": "S3Compatible",
"config": {
"bucket_name": bucket_name,
"region": "us-east-1",
@@ -68,7 +68,6 @@ async def gcs_batch_export(
"endpoint_url": "https://storage.googleapis.com",
"compression": compression,
"exclude_events": exclude_events,
- "encryption": None,
"file_format": file_format,
},
}
@@ -139,4 +138,5 @@ async def test_s3_export_workflow_with_gcs_bucket_with_various_file_formats(
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=s3_client,
+ destination_type="S3Compatible",
)
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_minio_bucket.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_minio_bucket.py
index cb89f32e9e6e..fdeb091e06a5 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_minio_bucket.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_minio_bucket.py
@@ -27,7 +27,7 @@ async def test_s3_export_workflow_with_minio_bucket_with_various_intervals_and_m
clickhouse_client,
minio_client,
ateam,
- s3_batch_export,
+ s3_compatible_batch_export,
bucket_name,
interval,
compression,
@@ -54,13 +54,14 @@ async def test_s3_export_workflow_with_minio_bucket_with_various_intervals_and_m
await run_s3_batch_export_workflow(
model=model,
ateam=ateam,
- batch_export_id=str(s3_batch_export.id),
- s3_destination_config=s3_batch_export.destination.config,
+ batch_export_id=str(s3_compatible_batch_export.id),
+ s3_destination_config=s3_compatible_batch_export.destination.config,
interval=interval,
data_interval_start=data_interval_start,
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=minio_client,
+ destination_type="S3Compatible",
)
@@ -73,7 +74,7 @@ async def test_s3_export_workflow_with_minio_bucket_with_various_compression_and
clickhouse_client,
minio_client,
ateam,
- s3_batch_export,
+ s3_compatible_batch_export,
bucket_name,
interval,
compression,
@@ -93,13 +94,14 @@ async def test_s3_export_workflow_with_minio_bucket_with_various_compression_and
await run_s3_batch_export_workflow(
model=model,
ateam=ateam,
- batch_export_id=str(s3_batch_export.id),
- s3_destination_config=s3_batch_export.destination.config,
+ batch_export_id=str(s3_compatible_batch_export.id),
+ s3_destination_config=s3_compatible_batch_export.destination.config,
interval=interval,
data_interval_start=data_interval_start,
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=minio_client,
+ destination_type="S3Compatible",
)
@@ -112,7 +114,7 @@ async def test_s3_export_workflow_with_minio_bucket_with_exclude_events(
clickhouse_client,
minio_client,
ateam,
- s3_batch_export,
+ s3_compatible_batch_export,
bucket_name,
interval,
compression,
@@ -131,13 +133,14 @@ async def test_s3_export_workflow_with_minio_bucket_with_exclude_events(
await run_s3_batch_export_workflow(
model=model,
ateam=ateam,
- batch_export_id=str(s3_batch_export.id),
- s3_destination_config=s3_batch_export.destination.config,
+ batch_export_id=str(s3_compatible_batch_export.id),
+ s3_destination_config=s3_compatible_batch_export.destination.config,
interval=interval,
data_interval_start=data_interval_start,
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=minio_client,
+ destination_type="S3Compatible",
)
@@ -153,7 +156,7 @@ async def test_s3_export_workflow_backfill_earliest_persons_with_minio_bucket(
clickhouse_client,
minio_client,
ateam,
- s3_batch_export,
+ s3_compatible_batch_export,
bucket_name,
interval,
compression,
@@ -185,14 +188,15 @@ async def test_s3_export_workflow_backfill_earliest_persons_with_minio_bucket(
await run_s3_batch_export_workflow(
model=model,
ateam=ateam,
- batch_export_id=str(s3_batch_export.id),
- s3_destination_config=s3_batch_export.destination.config,
+ batch_export_id=str(s3_compatible_batch_export.id),
+ s3_destination_config=s3_compatible_batch_export.destination.config,
interval=interval,
data_interval_start=data_interval_start,
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=minio_client,
backfill_details=backfill_details,
+ destination_type="S3Compatible",
)
@@ -205,7 +209,7 @@ async def test_s3_export_workflow_with_minio_bucket_without_events(
clickhouse_client,
minio_client,
ateam,
- s3_batch_export,
+ s3_compatible_batch_export,
bucket_name,
interval,
compression,
@@ -223,14 +227,57 @@ async def test_s3_export_workflow_with_minio_bucket_without_events(
await run_s3_batch_export_workflow(
model=model,
ateam=ateam,
- batch_export_id=str(s3_batch_export.id),
- s3_destination_config=s3_batch_export.destination.config,
+ batch_export_id=str(s3_compatible_batch_export.id),
+ s3_destination_config=s3_compatible_batch_export.destination.config,
interval=interval,
data_interval_start=data_interval_start,
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=minio_client,
expect_no_data=True,
+ destination_type="S3Compatible",
+ )
+
+
[email protected]("interval", ["hour"], indirect=True)
[email protected]("compression", [None], indirect=True)
[email protected]("exclude_events", [None], indirect=True)
[email protected]("file_format", ["JSONLines"], indirect=True)
[email protected]("model", [BatchExportModel(name="events", schema=None)])
+async def test_s3_export_workflow_with_legacy_s3_destination_type(
+ clickhouse_client,
+ minio_client,
+ ateam,
+ s3_compatible_batch_export,
+ bucket_name,
+ interval,
+ compression,
+ exclude_events,
+ file_format,
+ s3_key_prefix,
+ model,
+ data_interval_start,
+ data_interval_end,
+ generate_test_data,
+):
+ """Cover the legacy `S3` dispatch path through the canonical `S3BatchExportInputs`.
+
+ Production rows with `type="S3"` continue to dispatch via the canonical input
+ dataclass until reclassification runs.
+
+ TODO: This test can be removed once we have deprecated the legacy `S3` destination type.
+ """
+ await run_s3_batch_export_workflow(
+ model=model,
+ ateam=ateam,
+ batch_export_id=str(s3_compatible_batch_export.id),
+ s3_destination_config=s3_compatible_batch_export.destination.config,
+ interval=interval,
+ data_interval_start=data_interval_start,
+ data_interval_end=data_interval_end,
+ clickhouse_client=clickhouse_client,
+ s3_client=minio_client,
+ destination_type="S3",
)
@@ -253,7 +300,7 @@ async def test_s3_export_workflow_with_minio_bucket_and_custom_key_prefix(
bucket_name,
compression,
interval,
- s3_batch_export,
+ s3_compatible_batch_export,
s3_key_prefix,
data_interval_end,
data_interval_start,
@@ -270,11 +317,12 @@ async def test_s3_export_workflow_with_minio_bucket_and_custom_key_prefix(
await run_s3_batch_export_workflow(
model=model,
ateam=ateam,
- batch_export_id=str(s3_batch_export.id),
- s3_destination_config=s3_batch_export.destination.config,
+ batch_export_id=str(s3_compatible_batch_export.id),
+ s3_destination_config=s3_compatible_batch_export.destination.config,
interval=interval,
data_interval_start=data_interval_start,
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=minio_client,
+ destination_type="S3Compatible",
)
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py
index 8cd0208bfad0..7b00ae422f01 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py
@@ -59,14 +59,13 @@ async def s3_batch_export(
file_format,
):
destination_data = {
- "type": "S3",
+ "type": "AwsS3",
"config": {
"bucket_name": bucket_name,
"region": "us-east-1",
"prefix": s3_key_prefix,
"aws_access_key_id": os.getenv("AWS_ACCESS_KEY_ID"),
"aws_secret_access_key": os.getenv("AWS_SECRET_ACCESS_KEY"),
- "endpoint_url": None,
"compression": compression,
"exclude_events": exclude_events,
"encryption": encryption,
@@ -143,6 +142,7 @@ async def test_s3_export_workflow_with_s3_bucket_with_various_intervals_and_mode
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=s3_client,
+ destination_type="AwsS3",
)
@@ -187,4 +187,5 @@ async def test_s3_export_workflow_with_s3_bucket_with_various_file_formats(
data_interval_end=data_interval_end,
clickhouse_client=clickhouse_client,
s3_client=s3_client,
+ destination_type="AwsS3",
)
diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py b/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
index 7a8a0cd4b3ed..b7c8f524a4fc 100644
--- a/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py
@@ -5,6 +5,7 @@ import typing as t
import asyncio
import datetime as dt
import operator
+import dataclasses
from django.conf import settings
from django.test import override_settings
@@ -19,11 +20,18 @@ from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from posthog.temporal.common.clickhouse import ClickHouseClient
from posthog.temporal.tests.utils.models import afetch_batch_export_runs
-from products.batch_exports.backend.service import BackfillDetails, BatchExportModel, BatchExportSchema
+from products.batch_exports.backend.service import (
+ AwsS3BatchExportInputs,
+ BackfillDetails,
+ BatchExportModel,
+ BatchExportSchema,
+ S3BatchExportInputs,
+ S3CompatibleBatchExportInputs,
+ S3FamilyBaseInputs,
+)
from products.batch_exports.backend.temporal.batch_exports import finish_batch_export_run, start_batch_export_run
from products.batch_exports.backend.temporal.destinations.s3_batch_export import (
COMPRESSION_EXTENSIONS,
- S3BatchExportInputs,
S3BatchExportWorkflow,
S3InsertInputs,
insert_into_s3_activity_from_stage,
@@ -38,6 +46,12 @@ from products.batch_exports.backend.temporal.spmc import Producer, RecordBatchQu
from products.batch_exports.backend.tests.temporal.utils.records import get_record_batch_from_queue
from products.batch_exports.backend.tests.temporal.utils.s3 import assert_file_in_s3, assert_no_files_in_s3
+_INPUTS_BY_DESTINATION_TYPE: dict[str, type[S3BatchExportInputs] | type[S3FamilyBaseInputs]] = {
+ "S3": S3BatchExportInputs,
+ "AwsS3": AwsS3BatchExportInputs,
+ "S3Compatible": S3CompatibleBatchExportInputs,
+}
+
COMPRESSION_OPTIONS = [*COMPRESSION_EXTENSIONS.keys(), None]
TEST_S3_MODELS: list[BatchExportModel | BatchExportSchema | None] = [
@@ -314,10 +328,16 @@ async def run_s3_batch_export_workflow(
s3_client,
backfill_details: BackfillDetails | None = None,
expect_no_data: bool = False,
+ destination_type: str = "S3",
):
"""Run the S3 batch export workflow and assert it completes successfully.
This is a shared helper function used by tests for S3, GCS, and MinIO buckets.
+
+ `destination_type` selects which input dataclass is constructed and passed
+ to the workflow — exercising the per-destination → canonical-inputs adaptation
+ that happens in production. Defaults to the legacy "S3" type for backwards
+ compatibility with any callers that still need it.
"""
batch_export_schema: BatchExportSchema | None = None
batch_export_model: BatchExportModel | None = None
@@ -343,7 +363,8 @@ async def run_s3_batch_export_workflow(
)
workflow_id = str(uuid.uuid4())
- inputs = S3BatchExportInputs(
+ inputs_cls = _INPUTS_BY_DESTINATION_TYPE[destination_type]
+ per_destination_inputs = inputs_cls(
team_id=ateam.pk,
batch_export_id=batch_export_id,
data_interval_end=data_interval_end.isoformat(),
@@ -353,6 +374,7 @@ async def run_s3_batch_export_workflow(
backfill_details=backfill_details,
**s3_destination_config,
)
+ workflow_inputs = S3BatchExportInputs(**dataclasses.asdict(per_destination_inputs))
async with await WorkflowEnvironment.start_time_skipping() as activity_environment:
async with Worker(
@@ -369,7 +391,7 @@ async def run_s3_batch_export_workflow(
):
await activity_environment.client.execute_workflow(
S3BatchExportWorkflow.run,
- inputs,
+ workflow_inputs,
id=workflow_id,
task_queue=settings.BATCH_EXPORTS_TASK_QUEUE,
retry_policy=RetryPolicy(maximum_attempts=1),
diff --git a/products/batch_exports/frontend/generated/api.schemas.ts b/products/batch_exports/frontend/generated/api.schemas.ts
index 449e7019fb57..1e5008c45dd8 100644
--- a/products/batch_exports/frontend/generated/api.schemas.ts
+++ b/products/batch_exports/frontend/generated/api.schemas.ts
@@ -28,6 +28,8 @@ export const BlankEnumApi = {
/**
* * `S3` - S3
+ * `AwsS3` - Aws S3
+ * `S3Compatible` - S3 Compatible
* `Snowflake` - Snowflake
* `Postgres` - Postgres
* `Redshift` - Redshift
@@ -44,6 +46,8 @@ export type BatchExportDestinationTypeEnumApi =
export const BatchExportDestinationTypeEnumApi = {
S3: 'S3',
+ AwsS3: 'AwsS3',
+ S3Compatible: 'S3Compatible',
Snowflake: 'Snowflake',
Postgres: 'Postgres',
Redshift: 'Redshift',
@@ -193,6 +197,8 @@ export interface BatchExportDestinationApi {
/** A choice of supported BatchExportDestination types.
* `S3` - S3
+ * `AwsS3` - Aws S3
+ * `S3Compatible` - S3 Compatible
* `Snowflake` - Snowflake
* `Postgres` - Postgres
* `Redshift` - Redshift
diff --git a/products/batch_exports/frontend/generated/api.zod.ts b/products/batch_exports/frontend/generated/api.zod.ts
index 5bec25828713..d22822f92cb5 100644
--- a/products/batch_exports/frontend/generated/api.zod.ts
+++ b/products/batch_exports/frontend/generated/api.zod.ts
@@ -809,6 +809,8 @@ export const BatchExportsPauseCreateBody = /* @__PURE__ */ zod
type: zod
.enum([
'S3',
+ 'AwsS3',
+ 'S3Compatible',
'Snowflake',
'Postgres',
'Redshift',
@@ -821,10 +823,10 @@ export const BatchExportsPauseCreateBody = /* @__PURE__ */ zod
'FileDownload',
])
.describe(
- '\* `S3` - S3\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'
+ '\* `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'
)
.describe(
- 'A choice of supported BatchExportDestination types.\n\n\* `S3` - S3\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\* `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'
),
config: zod
.union([
@@ -1006,6 +1008,8 @@ export const BatchExportsRunTestStepCreateBody = /* @__PURE__ */ zod
type: zod
.enum([
'S3',
+ 'AwsS3',
+ 'S3Compatible',
'Snowflake',
'Postgres',
'Redshift',
@@ -1018,10 +1022,10 @@ export const BatchExportsRunTestStepCreateBody = /* @__PURE__ */ zod
'FileDownload',
])
.describe(
- '\* `S3` - S3\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'
+ '\* `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'
)
.describe(
- 'A choice of supported BatchExportDestination types.\n\n\* `S3` - S3\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\* `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'
),
config: zod
.union([
@@ -1214,6 +1218,8 @@ export const BatchExportsUnpauseCreateBody = /* @__PURE__ */ zod
type: zod
.enum([
'S3',
+ 'AwsS3',
+ 'S3Compatible',
'Snowflake',
'Postgres',
'Redshift',
@@ -1226,10 +1232,10 @@ export const BatchExportsUnpauseCreateBody = /* @__PURE__ */ zod
'FileDownload',
])
.describe(
- '\* `S3` - S3\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'
+ '\* `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'
)
.describe(
- 'A choice of supported BatchExportDestination types.\n\n\* `S3` - S3\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\* `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'
),
config: zod
.union([
@@ -1415,6 +1421,8 @@ export const BatchExportsRunTestStepNewCreateBody = /* @__PURE__ */ zod
type: zod
.enum([
'S3',
+ 'AwsS3',
+ 'S3Compatible',
'Snowflake',
'Postgres',
'Redshift',
@@ -1427,10 +1435,10 @@ export const BatchExportsRunTestStepNewCreateBody = /* @__PURE__ */ zod
'FileDownload',
])
.describe(
- '\* `S3` - S3\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'
+ '\* `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'
)
.describe(
- 'A choice of supported BatchExportDestination types.\n\n\* `S3` - S3\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\* `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'
),
config: zod
.union([
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index f076fbb1f5ab..52aeaa401ae7 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -8440,6 +8440,8 @@ export namespace Schemas {
/**
* * `S3` - S3
+ * `AwsS3` - Aws S3
+ * `S3Compatible` - S3 Compatible
* `Snowflake` - Snowflake
* `Postgres` - Postgres
* `Redshift` - Redshift
@@ -8456,6 +8458,8 @@ export namespace Schemas {
export const BatchExportDestinationTypeEnum = {
S3: 'S3',
+ AwsS3: 'AwsS3',
+ S3Compatible: 'S3Compatible',
Snowflake: 'Snowflake',
Postgres: 'Postgres',
Redshift: 'Redshift',
@@ -8535,6 +8539,8 @@ export namespace Schemas {
/** A choice of supported BatchExportDestination types.
* `S3` - S3
+ * `AwsS3` - Aws S3
+ * `S3Compatible` - S3 Compatible
* `Snowflake` - Snowflake
* `Postgres` - Postgres
* `Redshift` - Redshift