:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(batch-exports): require an integration for S3 batch exports (#90957)
Ross2011c33769cb
diff --git a/products/batch_exports/backend/api/batch_export.py b/products/batch_exports/backend/api/batch_export.pyindex 205951e65b1d..bbfe18b8fa40 100644--- a/products/batch_exports/backend/api/batch_export.py+++ b/products/batch_exports/backend/api/batch_export.py@@ -50,7 +50,6 @@ from posthog.utils import relative_date_parse, str_to_boolfrom products.batch_exports.backend.api.destination_tests import get_destination_testfrom products.batch_exports.backend.models.batch_export import (BATCH_EXPORT_INTERVALS,- S3_CREATABLE_TYPES,S3_FAMILY_TYPES,TIMEZONES,BatchExport,@@ -697,7 +696,7 @@ class AwsS3DestinationRequestSerializer(serializers.Serializer):type = serializers.ChoiceField(choices=["AwsS3"])integration_id = serializers.IntegerField(help_text=(- "ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. "+ "ID of an aws-s3-kind Integration providing AWS credentials. ""Use the integrations-list MCP tool to find one."),)@@ -711,7 +710,7 @@ class S3CompatibleDestinationRequestSerializer(serializers.Serializer):integration_id = serializers.IntegerField(help_text=("ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. "- "Required when creating a batch export. Use the integrations-list MCP tool to find one."+ "Use the integrations-list MCP tool to find one."),)config = S3CompatibleDestinationConfigSerializer()@@ -885,9 +884,9 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):required=False,allow_null=True,help_text=(- "ID of a team-scoped Integration providing credentials. Required when creating Databricks, "- "AzureBlob, BigQuery, Postgres, AwsS3, and S3Compatible destinations; optional for Snowflake "- "and Redshift (inline credentials remain supported); unused for other types."+ "ID of a team-scoped Integration providing credentials, for destinations that authenticate "+ "through one. Required for all of those except Snowflake, which still supports inline "+ "credentials."),)@@ -927,19 +926,13 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):# Some credential/connection fields are optional on the dataclass (integration-backed exports# resolve them at run time), so they must be required here only when no Integration is linked.- # For the S3 family this is only possible when updating an export that predates integrations:- # creating one without an Integration is rejected in `validate_destination`. Redshift is- # absent for the same reason, and because this check runs first: leaving it in would report a- # missing 'user' instead of the missing integration that is the actual problem.- # TODO: remove this code once inline credentials are gone for S3 and integrations are enforced- # for Snowflake+ # Only Snowflake needs this. Every other destination requires an Integration, so+ # `validate_destination` reports a missing one. Listing them here would report a missing+ # credential field instead, because this check runs first.+ # TODO: remove this code once integrations are enforced for Snowflakeconditionally_required: set[str] = set()if attrs.get("integration") is None:- if export_type in S3_FAMILY_TYPES:- conditionally_required = {"aws_access_key_id", "aws_secret_access_key"}- if export_type == BatchExportDestination.Destination.S3_COMPATIBLE:- conditionally_required.add("endpoint_url")- elif export_type == BatchExportDestination.Destination.SNOWFLAKE:+ if export_type == BatchExportDestination.Destination.SNOWFLAKE:conditionally_required = {"account", "user"}for destination_field in destination_fields:@@ -1433,11 +1426,11 @@ class BatchExportSerializer(serializers.ModelSerializer):"Delete this batch export and create a new one with the new destination type.")- # The legacy `S3` type is retained only for existing rows; new destinations must use the- # refined `AwsS3` or `S3Compatible` types. `instance is None` means we're creating.- if instance is None and destination_type == BatchExportDestination.Destination.S3:+ # The legacy `S3` type predates both the AwsS3/S3Compatible split and integration-backed+ # credentials. Every row has been migrated off it, so it accepts no writes at all.+ if destination_type == BatchExportDestination.Destination.S3:raise serializers.ValidationError(- "The 'S3' destination type is deprecated and can no longer be created. "+ "The 'S3' destination type is deprecated and can no longer be used. ""Use 'AwsS3' for AWS S3, or 'S3Compatible' for S3-compatible storage.")@@ -1473,26 +1466,30 @@ class BatchExportSerializer(serializers.ModelSerializer):if destination_type in S3_FAMILY_TYPES:integration = destination_attrs.get("integration")+ if integration is None and "integration" not in destination_attrs and instance is not None:+ # A PATCH may send config alone, which keeps the export's existing integration.+ # An explicit `integration: null` is a removal, and is rejected below.+ integration = instance.destination.integration- # TODO: remove this guard once integrations are mandatory for S3 and inline credentials are gone.- if instance is not None and instance.destination.integration is not None and integration is None:+ if integration is None:+ raise serializers.ValidationError(f"Integration is required for {destination_type} batch exports")++ # Credentials and the provider endpoint live in the integration. Only the submitted+ # config is checked: rows migrated off inline credentials still hold these keys in+ # stored config, and patching one must not resurface them as an error. Any other+ # credential field is already rejected as unknown, since the input dataclasses never+ # declared it.+ integration_owned_fields = {"aws_access_key_id", "aws_secret_access_key", "endpoint_url"}+ submitted_owned_fields = sorted(integration_owned_fields & config.keys())+ if submitted_owned_fields:raise serializers.ValidationError(- "Cannot remove the integration from an S3 batch export that uses one. "- "Re-send its `integration` to keep it (or a different one to swap)."+ f"{destination_type} batch exports authenticate through their integration. "+ f"Remove these fields from the configuration: {submitted_owned_fields}")- # New S3 exports must use an Integration for credentials. Exports created before- # integrations existed keep their inline credentials, so only require it on create- # (`instance is None`); existing inline-credential exports stay valid when edited.- if integration is None and instance is None and destination_type in S3_CREATABLE_TYPES:- raise serializers.ValidationError(f"Integration is required for {destination_type} batch exports")-# we already validate the required inputs in BatchExportDestinationSerializer::validate# so here we just ensure that the inputs are not emptyrequired_non_empty_inputs = ["bucket_name", "region", "prefix"]- # Credentials are only required inline when no Integration provides them.- if integration is None:- required_non_empty_inputs += ["aws_access_key_id", "aws_secret_access_key", "aws_role_arn"]empty_inputs = []@@ -1504,24 +1501,13 @@ class BatchExportSerializer(serializers.ModelSerializer):if empty_inputs:raise serializers.ValidationError(f"The following inputs are empty: {empty_inputs}")- # When an Integration is supplied it must match the destination kind. (Team ownership is- # already enforced by the team-scoped `integration` field, which can only resolve- # integrations belonging to the request's team.)- if integration is not None:- # An Integration only makes sense for the integration-backed S3 types. Reject it on the- # legacy "S3" type- # TODO: remove this branch once the legacy "S3" destination type is fully removed- try:- kind = S3_DESTINATION_TO_INTEGRATION_KIND[destination_type]- except KeyError:- raise serializers.ValidationError(- f"{destination_type} destinations do not support integration-based credentials."- )-- if not integration.kind == kind:- raise serializers.ValidationError(- f"Integration provided is not an AWS S3 integration (got kind='{integration.kind}')"- )+ # The integration must match the destination kind. (Team ownership is already enforced+ # by the team-scoped `integration` field, which can only resolve integrations belonging+ # to the request's team.)+ if integration.kind != S3_DESTINATION_TO_INTEGRATION_KIND[destination_type]:+ raise serializers.ValidationError(+ f"Integration provided is not an AWS S3 integration (got kind='{integration.kind}')"+ )# JSONLines is the default file format for S3 exports for legacy reasonsfile_format = merged_config.get("file_format", "JSONLines")@@ -1536,16 +1522,6 @@ class BatchExportSerializer(serializers.ModelSerializer):f"Compression {compression} is not supported for file format {file_format}. Supported compressions are {S3_SUPPORTED_COMPRESSIONS[file_format]}")- # if someone is trying to reset the endpoint url, then we need to convert empty string to None- if merged_config.get("endpoint_url") == "":- destination_attrs["config"]["endpoint_url"] = None-- if merged_config.get("endpoint_url") is not None:- try:- resolve_and_validate_url(merged_config["endpoint_url"])- except ValueError:- raise serializers.ValidationError(f"Invalid endpoint_url: '{merged_config['endpoint_url']}'")-if destination_type == BatchExportDestination.Destination.DATABRICKS:# validate the Integration is valid (this is mandatory for Databricks batch exports)integration = destination_attrs.get("integration")diff --git a/products/batch_exports/backend/api/destination_tests/__init__.py b/products/batch_exports/backend/api/destination_tests/__init__.pyindex 969ab6a99a25..b1065dd1c975 100644--- a/products/batch_exports/backend/api/destination_tests/__init__.py+++ b/products/batch_exports/backend/api/destination_tests/__init__.py@@ -10,7 +10,7 @@ def get_destination_test((databricks, google-cloud-bigquery, snowflake, etc.). Importing them lazily keeps theSDKs off the API import path — only the requested destination's SDK loads."""- if destination in ("S3", "S3Compatible"):+ if destination == "S3Compatible":from products.batch_exports.backend.api.destination_tests.s3 import S3CompatibleDestinationTest # noqa: PLC0415return S3CompatibleDestinationTest()diff --git a/products/batch_exports/backend/models/batch_export.py b/products/batch_exports/backend/models/batch_export.pyindex 2ea443fe8151..3ed6162ab2e0 100644--- a/products/batch_exports/backend/models/batch_export.py+++ b/products/batch_exports/backend/models/batch_export.py@@ -24,13 +24,9 @@ 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"})--# S3-family types that can be created via the API. The legacy "S3" type is excluded:-# existing rows keep working, but new destinations must use "AwsS3" or "S3Compatible".-S3_CREATABLE_TYPES: frozenset[str] = frozenset({"AwsS3", "S3Compatible"})+# S3-family destination types that are in use. Note that this excludes the legacy "S3"+# type which has now been fully deprecated.+S3_FAMILY_TYPES: frozenset[str] = frozenset({"AwsS3", "S3Compatible"})class DayOfWeek(IntEnum):@@ -70,7 +66,7 @@ class BatchExportDestination(UUIDTModel):class Destination(models.TextChoices):"""Enumeration of supported destinations for PostHog BatchExports."""- S3 = "S3" # legacy alias; AwsS3 / S3Compatible are the preferred types for new rows+ S3 = "S3" # TODO: legacy alias which is no longer used so can be removedAWS_S3 = "AwsS3"S3_COMPATIBLE = "S3Compatible"SNOWFLAKE = "Snowflake"@@ -84,6 +80,9 @@ class BatchExportDestination(UUIDTModel):NOOP = "NoOp"FILE_DOWNLOAD = "FileDownload"+ # S3-family exports read their credentials from an Integration, but rows migrated off inline+ # credentials still hold them in `config`. These entries keep those stale values out of API+ # responses until a follow-up strips them from stored config.secret_fields = {"S3": {"aws_access_key_id", "aws_secret_access_key"},"AwsS3": {"aws_access_key_id", "aws_secret_access_key"},diff --git a/products/batch_exports/backend/tests/api/backfills/test_cancel.py b/products/batch_exports/backend/tests/api/backfills/test_cancel.pyindex 6f90fa1fcb49..0fd2afcff1a2 100644--- a/products/batch_exports/backend/tests/api/backfills/test_cancel.py+++ b/products/batch_exports/backend/tests/api/backfills/test_cancel.py@@ -62,8 +62,6 @@ def test_cancelling_a_batch_export_backfill(client: HttpClient, organization, te"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 = {diff --git a/products/batch_exports/backend/tests/api/backfills/test_create.py b/products/batch_exports/backend/tests/api/backfills/test_create.pyindex 9e485bba0ec6..3234675acf25 100644--- a/products/batch_exports/backend/tests/api/backfills/test_create.py+++ b/products/batch_exports/backend/tests/api/backfills/test_create.py@@ -43,8 +43,6 @@ def _create_batch_export_ok("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 = {diff --git a/products/batch_exports/backend/tests/api/conftest.py b/products/batch_exports/backend/tests/api/conftest.pyindex f3436d0045f8..3d0afb2fc2b7 100644--- a/products/batch_exports/backend/tests/api/conftest.py+++ b/products/batch_exports/backend/tests/api/conftest.py@@ -132,6 +132,27 @@ def s3_compatible_integration(team, user):)+def s3_batch_export_data(aws_s3_integration) -> dict:+ """Return the request body for creating a minimal AwsS3 batch export.++ Function scoped, so a test may change the returned dictionary without affecting other tests.+ """+ return {+ "name": "my-production-s3-bucket-destination",+ "destination": {+ "type": "AwsS3",+ "integration": aws_s3_integration.id,+ "config": {+ "bucket_name": "my-production-s3-bucket",+ "region": "us-east-1",+ "prefix": "posthog-events/",+ },+ },+ "interval": "hour",+ }++def assert_is_daily_schedule(schedule: ScheduleDescription, expected_hour: int):"""Assert the schedule is a daily schedule."""calendars = schedule.schedule.spec.calendarsdiff --git a/products/batch_exports/backend/tests/api/destination_tests/test_s3_destination_tests.py b/products/batch_exports/backend/tests/api/destination_tests/test_s3_destination_tests.pyindex a71eaa25ac35..52e26ae42070 100644--- a/products/batch_exports/backend/tests/api/destination_tests/test_s3_destination_tests.py+++ b/products/batch_exports/backend/tests/api/destination_tests/test_s3_destination_tests.py@@ -120,7 +120,6 @@ async def test_assume_role_step_skips_without_role():@pytest.mark.parametrize("destination,expected_test,expected_steps",[- ("S3", S3CompatibleDestinationTest, [S3EnsureBucketTestStep]),("S3Compatible", S3CompatibleDestinationTest, [S3EnsureBucketTestStep]),("AwsS3", AwsS3DestinationTest, [S3AssumeRoleTestStep, S3EnsureBucketTestStep]),],diff --git a/products/batch_exports/backend/tests/api/test_create.py b/products/batch_exports/backend/tests/api/test_create.pyindex 56ee522ad2b2..b41cdbc1c792 100644--- a/products/batch_exports/backend/tests/api/test_create.py+++ b/products/batch_exports/backend/tests/api/test_create.py@@ -6,7 +6,6 @@ from zoneinfo import ZoneInfoimport pytestfrom unittest import mock-from django.test import override_settingsfrom django.test.client import Client as HttpClientfrom asgiref.sync import async_to_sync@@ -54,9 +53,6 @@ def test_create_batch_export_with_interval_schedule("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": s3_compatible_integration.id,@@ -80,10 +76,6 @@ def test_create_batch_export_with_interval_schedule(data = response.json()- # We should not get the aws_access_key_id or aws_secret_access_key back, so- # remove that from the data we expect.- batch_export_data["destination"]["config"].pop("aws_access_key_id")- batch_export_data["destination"]["config"].pop("aws_secret_access_key")assert data["destination"] == batch_export_data["destination"]# We should match on top level fields.@@ -114,9 +106,11 @@ def test_create_batch_export_with_interval_schedule(assert args["bucket_name"] == "my-production-s3-bucket"assert args["region"] == "us-east-1"assert args["prefix"] == "posthog-events/"- assert args["aws_access_key_id"] == "abc123"- assert args["aws_secret_access_key"] == "secret"assert args["use_virtual_style_addressing"]+ # Credentials are resolved from the integration at run time, never carried in the schedule.+ assert args["integration_id"] == s3_compatible_integration.id+ assert args.get("aws_access_key_id") is None+ assert args.get("aws_secret_access_key") is None# Temporal UI metadata should be set on the schedule's actionassert schedule.schedule.action.static_summary is not None@@ -191,8 +185,6 @@ def test_create_batch_export_with_different_intervals_timezones_and_interval_off"bucket_name": "my-production-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",},}@@ -347,8 +339,6 @@ def test_cannot_create_a_batch_export_for_another_organization(client: HttpClien"bucket_name": "my-production-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",},}@@ -423,25 +413,9 @@ def test_cannot_create_batch_export_with_integration_from_another_team(def test_cannot_create_a_batch_export_with_higher_frequencies_if_not_enabled(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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": "every 5 minutes",- }+ batch_export_data = {**s3_batch_export_data, "interval": "every 5 minutes"}client.force_login(user)with mock.patch(@@ -481,7 +455,7 @@ FROM eventsdef test_create_batch_export_with_custom_schema(- client: HttpClient, temporal, encryption_codec, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, encryption_codec, organization, team, user, s3_batch_export_data):"""Test creating a BatchExport with a custom schema expressed as a HogQL Query.@@ -491,24 +465,7 @@ def test_create_batch_export_with_custom_schema(expected inputs."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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,- "hogql_query": TEST_HOGQL_QUERY,- "interval": "hour",- }+ batch_export_data = {**s3_batch_export_data, "hogql_query": TEST_HOGQL_QUERY}client.force_login(user)@@ -603,28 +560,18 @@ def test_create_batch_export_with_custom_schema(],)def test_create_batch_export_fails_with_invalid_query(- client: HttpClient, invalid_query, expected_error_message, temporal, organization, team, user, aws_s3_integration+ client: HttpClient,+ invalid_query,+ expected_error_message,+ temporal,+ organization,+ team,+ user,+ s3_batch_export_data,):"""Test creating a BatchExport should fail with an invalid query."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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",- "hogql_query": invalid_query,- }+ batch_export_data = {**s3_batch_export_data, "hogql_query": invalid_query}client.force_login(user)@@ -661,8 +608,6 @@ def test_create_batch_export_fails_with_invalid_query("bucket_name": "my-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret","hello": 123, # Unknown field"hello2": 123, # Another unknown field},@@ -726,8 +671,6 @@ _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",}@@ -791,53 +734,3 @@ def test_creating_batch_export_with_filters(if expected_error:assert expected_error in response.json()["detail"]--- "host",- [- "192.168.1.1",- "127.0.0.1",- "[::1]",- "10.0.0.1",- "169.254.0.0",- "localhost",- ],-)-def test_create_redshift_batch_export_fails_with_invalid_host(- client: HttpClient, temporal, organization, team, user, host, aws_redshift_integration-):- """Test creating a BatchExport with Redshift destination validates inputs for 'COPY'.-- Postgres host validation is covered separately in test_create_postgres.py, where the host- comes from the linked Integration rather than from inline config.- """-- destination_data = {- "type": "Redshift",- "config": {- "database": "my-db",- "host": host,- "schema": "public",- "table_name": "my_events",- },- "integration": aws_redshift_integration.pk,- }-- batch_export_data = {- "name": "my-production-destination",- "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 host: '{host}'" in response.json()["detail"]diff --git a/products/batch_exports/backend/tests/api/test_create_redshift.py b/products/batch_exports/backend/tests/api/test_create_redshift.pyindex 4aed311a92e4..81742cb6fb11 100644--- a/products/batch_exports/backend/tests/api/test_create_redshift.py+++ b/products/batch_exports/backend/tests/api/test_create_redshift.py@@ -1,5 +1,6 @@import pytest+from django.test import override_settingsfrom django.test.client import Client as HttpClientfrom rest_framework import status@@ -198,6 +199,56 @@ def test_create_redshift_batch_export_rejects_invalid_authorization_type(assert "Authorization for 'COPY'" in response.json()["detail"]+ "host",+ [+ "192.168.1.1",+ "127.0.0.1",+ "[::1]",+ "10.0.0.1",+ "169.254.0.0",+ "localhost",+ ],+)+def test_create_redshift_batch_export_fails_with_invalid_host(+ client: HttpClient, temporal, organization, team, user, host, aws_redshift_integration+):+ """Test creating a BatchExport with a Redshift destination rejects an internal host.++ Postgres host validation is covered separately in test_create_postgres.py, where the host+ comes from the linked Integration rather than from inline config.+ """++ destination_data = {+ "type": "Redshift",+ "config": {+ "database": "my-db",+ "host": host,+ "schema": "public",+ "table_name": "my_events",+ },+ "integration": aws_redshift_integration.pk,+ }++ batch_export_data = {+ "name": "my-production-destination",+ "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 host: '{host}'" in response.json()["detail"]++def test_create_redshift_batch_export_with_aws_integration(client: HttpClient, temporal, organization, team, user, aws_redshift_integration):diff --git a/products/batch_exports/backend/tests/api/test_create_s3.py b/products/batch_exports/backend/tests/api/test_create_s3.pyindex d6dfbee00d70..d025cd5ae44b 100644--- a/products/batch_exports/backend/tests/api/test_create_s3.py+++ b/products/batch_exports/backend/tests/api/test_create_s3.py@@ -1,14 +1,11 @@-import typing as t-import pytest-from django.test import override_settingsfrom django.test.client import Client as HttpClientfrom rest_framework import statusfrom temporalio.client import ScheduleActionStartWorkflow-from products.batch_exports.backend.models.batch_export import S3_CREATABLE_TYPES+from products.batch_exports.backend.models.batch_export import S3_FAMILY_TYPESfrom products.batch_exports.backend.tests.api.conftest import describe_schedulefrom products.batch_exports.backend.tests.api.operations import create_batch_export@@ -21,8 +18,6 @@ _S3_FAMILY_BASE_CONFIG = {"bucket_name": "my-bucket","region": "us-east-1","prefix": "events/",- "aws_access_key_id": "key",- "aws_secret_access_key": "secret",}@@ -31,8 +26,8 @@ _S3_FAMILY_BASE_CONFIG = {[# Refined AwsS3 (with AWS-only encryption field)("AwsS3", "aws_s3_integration", {"encryption": "AES256"}, "AwsS3"),- # Refined S3Compatible (accepts an inline endpoint_url alongside the integration's)- ("S3Compatible", "s3_compatible_integration", {"endpoint_url": "https://localhost:9000"}, "S3Compatible"),+ # Refined S3Compatible (with its addressing-style field)+ ("S3Compatible", "s3_compatible_integration", {"use_virtual_style_addressing": True}, "S3Compatible"),],)def test_create_s3_family_batch_export(@@ -67,23 +62,19 @@ def test_create_s3_family_batch_export(assert response.json()["destination"]["type"] == expected_persisted_type[email protected]("destination_type", sorted(S3_CREATABLE_TYPES))[email protected]("destination_type", sorted(S3_FAMILY_TYPES))def test_create_s3_family_batch_export_requires_an_integration(client: HttpClient, temporal, organization, team, user, destination_type):- """Inline credentials are no longer enough to create an S3-family export: an Integration is required."""+ """An S3-family export cannot be created without an Integration to authenticate through."""client.force_login(user)- config = {**_S3_FAMILY_BASE_CONFIG}- if destination_type == "S3Compatible":- config["endpoint_url"] = "https://localhost:9000"-response = create_batch_export(client,team.pk,{"name": "my-export","interval": "hour",- "destination": {"type": destination_type, "config": config},+ "destination": {"type": destination_type, "config": {**_S3_FAMILY_BASE_CONFIG}},},)assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()@@ -126,8 +117,6 @@ def test_create_s3_family_batch_export_validates_empty_inputs(integration = request.getfixturevalue(integration_fixture)client.force_login(user)config = {**_S3_FAMILY_BASE_CONFIG, "bucket_name": "", "region": ""}- if destination_type == "S3Compatible":- config["endpoint_url"] = "https://localhost:9000"response = create_batch_export(client,@@ -143,43 +132,52 @@ def test_create_s3_family_batch_export_validates_empty_inputs(@pytest.mark.parametrize(- "destination_type,missing_field",+ "destination_type,integration_fixture,owned_field",[- *((dt, field) for dt in sorted(S3_CREATABLE_TYPES) for field in ("aws_access_key_id", "aws_secret_access_key")),- # `endpoint_url` is required only for S3Compatible.- ("S3Compatible", "endpoint_url"),+ ("AwsS3", "aws_s3_integration", "aws_access_key_id"),+ ("AwsS3", "aws_s3_integration", "aws_secret_access_key"),+ ("S3Compatible", "s3_compatible_integration", "aws_access_key_id"),+ ("S3Compatible", "s3_compatible_integration", "aws_secret_access_key"),+ # `endpoint_url` is an S3Compatible-only field; AwsS3 rejects it as unknown instead.+ ("S3Compatible", "s3_compatible_integration", "endpoint_url"),],)-def test_create_s3_family_batch_export_validates_missing_required_inputs(+def test_create_s3_family_batch_export_rejects_integration_owned_fields(client: HttpClient,temporal,organization,team,user,destination_type,- missing_field,+ integration_fixture,+ owned_field,+ request,):- """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)+ """Credentials and the provider endpoint belong to the integration, so config may not carry them.+ An accepted value here would be persisted in `config` and copied into the export's Temporal+ schedule arguments.+ """+ integration = request.getfixturevalue(integration_fixture)+ client.force_login(user)response = create_batch_export(client,team.pk,{"name": "my-export","interval": "hour",- "destination": {"type": destination_type, "config": config},+ "destination": {+ "type": destination_type,+ "config": {**_S3_FAMILY_BASE_CONFIG, owned_field: "belongs-in-the-integration"},+ "integration": integration.id,+ },},)assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()- assert f"missing required field: '{missing_field}'" in response.json()["detail"]+ assert response.json()["detail"] == (+ f"{destination_type} batch exports authenticate through their integration. "+ f"Remove these fields from the configuration: ['{owned_field}']"+ )@pytest.mark.parametrize(@@ -189,8 +187,8 @@ def test_create_s3_family_batch_export_validates_missing_required_inputs(("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"),+ ("S3Compatible", {"kms_key_id": "alias/test"}, "kms_key_id"),+ ("S3Compatible", {"encryption": "aws:kms"}, "encryption"),],)def test_create_s3_family_batch_export_rejects_inapplicable_fields(@@ -293,58 +291,6 @@ def test_create_s3_batch_export_validates_file_format_and_compression(assert response.json()["detail"] == expected_error_message- "destination_type",- # Only creatable types that accept `endpoint_url` reach the SSRF check.- ["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, s3_compatible_integration-):- """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": s3_compatible_integration.id,- }-- 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"]--@pytest.mark.parametrize("destination_type,integration_fixture",[diff --git a/products/batch_exports/backend/tests/api/test_delete.py b/products/batch_exports/backend/tests/api/test_delete.pyindex 3c35423d3d33..3de0b53256ea 100644--- a/products/batch_exports/backend/tests/api/test_delete.py+++ b/products/batch_exports/backend/tests/api/test_delete.py@@ -31,28 +31,11 @@ pytestmark = []-def test_delete_batch_export(client: HttpClient, temporal, organization, team, user, aws_s3_integration):+def test_delete_batch_export(client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test deleting a BatchExport."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)+ batch_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)batch_export_id = batch_export["id"]delete_batch_export_ok(client, team.pk, batch_export_id)@@ -91,29 +74,12 @@ async def wait_for_workflow_in_status(@pytest.mark.django_db(transaction=True)def test_delete_batch_export_cancels_backfills(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test deleting a BatchExport cancels ongoing BatchExportBackfill."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)+ batch_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)batch_export_id = batch_export["id"]# ensure there is data to backfill, otherwise validation will fail@@ -152,31 +118,14 @@ def test_delete_batch_export_cancels_backfills(def test_cannot_delete_export_of_other_organizations(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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",- }-another_organization = create_organization("Another Org")create_team(another_organization)another_user = create_user("[email protected]", "Another Test User", another_organization)client.force_login(user)- batch_export = create_batch_export_ok(client, team.pk, batch_export_data)+ batch_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)batch_export_id = batch_export["id"]client.force_login(another_user)@@ -189,28 +138,13 @@ def test_cannot_delete_export_of_other_organizations(assert response.status_code == status.HTTP_200_OK-def test_deletes_are_partitioned_by_team_id(client: HttpClient, temporal, organization, team, user, aws_s3_integration):- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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",- }-+def test_deletes_are_partitioned_by_team_id(+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data+):another_team = create_team(organization)client.force_login(user)- batch_export = create_batch_export_ok(client, team.pk, batch_export_data)+ batch_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)batch_export_id = batch_export["id"]# Try to delete with the other team@@ -224,29 +158,12 @@ def test_deletes_are_partitioned_by_team_id(client: HttpClient, temporal, organi@pytest.mark.django_db(transaction=True)def test_delete_batch_export_even_without_underlying_schedule(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test deleting a BatchExport completes even if underlying Schedule was already deleted."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)+ batch_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)batch_export_id = batch_export["id"]handle = temporal.get_schedule_handle(batch_export_id)diff --git a/products/batch_exports/backend/tests/api/test_get.py b/products/batch_exports/backend/tests/api/test_get.pyindex ec2a021841ea..f182491c9dad 100644--- a/products/batch_exports/backend/tests/api/test_get.py+++ b/products/batch_exports/backend/tests/api/test_get.py@@ -47,8 +47,6 @@ def test_can_get_exports_for_your_organizations("bucket_name": "my-production-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",},}@@ -97,26 +95,8 @@ def test_can_get_exports_for_your_organizations(def test_cannot_get_exports_for_other_organizations(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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",- }-another_organization = create_organization("Another Org")another_user = create_user("[email protected]", "Another Test User", another_organization)@@ -124,7 +104,7 @@ def test_cannot_get_exports_for_other_organizations(response = create_batch_export_ok(client,team.pk,- batch_export_data,+ s3_batch_export_data,)client.force_login(another_user)@@ -133,30 +113,12 @@ def test_cannot_get_exports_for_other_organizations(def test_batch_exports_are_partitioned_by_team(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""You shouldn't be able to fetch a BatchExport by id, via a team that itdoesn't belong to."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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",- }-another_team = create_team(organization)# Integrations are team-scoped, so the other team's export needs its own.another_team_integration = Integration.objects.create(@@ -172,7 +134,7 @@ def test_batch_exports_are_partitioned_by_team(batch_export = create_batch_export_ok(client,team.pk,- batch_export_data,+ s3_batch_export_data,)response = get_batch_export(client, another_team.pk, batch_export["id"])@@ -182,7 +144,10 @@ def test_batch_exports_are_partitioned_by_team(batch_export = create_batch_export_ok(client,another_team.pk,- {**batch_export_data, "destination": {**destination_data, "integration": another_team_integration.id}},+ {+ **s3_batch_export_data,+ "destination": {**s3_batch_export_data["destination"], "integration": another_team_integration.id},+ },)response = get_batch_export(client, team.pk, batch_export["id"])diff --git a/products/batch_exports/backend/tests/api/test_list.py b/products/batch_exports/backend/tests/api/test_list.pyindex df30d0d2f488..2ba11d4f4a93 100644--- a/products/batch_exports/backend/tests/api/test_list.py+++ b/products/batch_exports/backend/tests/api/test_list.py@@ -19,32 +19,14 @@ pytestmark = []-def test_list_batch_exports(client: HttpClient, organization, team, user, aws_s3_integration):+def test_list_batch_exports(client: HttpClient, organization, team, user, s3_batch_export_data):"""Should be able to list batch exports."""client.force_login(user)- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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",- }-- first_export = create_batch_export_ok(client, team.pk, batch_export_data)- second_export = create_batch_export_ok(client, team.pk, batch_export_data)+ first_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)+ second_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)response = list_batch_exports_ok(client, team.pk)assert len(response["results"]) == 2@@ -60,7 +42,7 @@ def test_list_batch_exports(client: HttpClient, organization, team, user, aws_s3def test_cannot_list_batch_exports_for_other_organizations(- client: HttpClient, organization, team, user, aws_s3_integration+ client: HttpClient, organization, team, user, s3_batch_export_data):"""Should not be able to list batch exports for other teams.@@ -69,27 +51,9 @@ def test_cannot_list_batch_exports_for_other_organizations(other_team = create_team(other_organization)other_user = create_user("[email protected]", "Another Test User", other_organization)- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)- create_batch_export_ok(client, team.pk, batch_export_data)- create_batch_export_ok(client, team.pk, batch_export_data)+ create_batch_export_ok(client, team.pk, s3_batch_export_data)+ create_batch_export_ok(client, team.pk, s3_batch_export_data)# Make sure we can list batch exports for our own team.response = list_batch_exports_ok(client, team.pk)@@ -100,33 +64,15 @@ def test_cannot_list_batch_exports_for_other_organizations(assert len(response["results"]) == 0-def test_list_is_partitioned_by_team(client: HttpClient, organization, team, user, aws_s3_integration):+def test_list_is_partitioned_by_team(client: HttpClient, organization, team, user, s3_batch_export_data):"""Should be able to list batch exports for a specific team."""another_team = create_team(organization)- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)- create_batch_export_ok(client, team.pk, batch_export_data)- create_batch_export_ok(client, team.pk, batch_export_data)+ create_batch_export_ok(client, team.pk, s3_batch_export_data)+ create_batch_export_ok(client, team.pk, s3_batch_export_data)# Make sure we can list batch exports for that team.response = list_batch_exports_ok(client, team.pk)@@ -159,31 +105,13 @@ def enable_backfilling_workflows(team):def test_list_filters_workflows_destination(- client: HttpClient, organization, team, user, aws_s3_integration, enable_backfilling_workflows+ client: HttpClient, organization, team, user, s3_batch_export_data, enable_backfilling_workflows):"""Workflows should be filtered out from the list."""client.force_login(user)- s3_destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "config": {- "bucket_name": "my-production-s3-bucket",- "region": "us-east-1",- "prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- }-- s3_batch_export_data = {- "name": "my-production-s3-bucket-destination",- "destination": s3_destination_data,- "interval": "hour",- }-realtime_destination_data = {"type": "Workflows","config": {diff --git a/products/batch_exports/backend/tests/api/test_pause.py b/products/batch_exports/backend/tests/api/test_pause.pyindex 02fec9f809fa..7cf4e752fba7 100644--- a/products/batch_exports/backend/tests/api/test_pause.py+++ b/products/batch_exports/backend/tests/api/test_pause.py@@ -25,32 +25,14 @@ pytestmark = []-def test_pause_and_unpause_batch_export(client: HttpClient, temporal, organization, team, user, aws_s3_integration):+def test_pause_and_unpause_batch_export(client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test pausing and unpausing a BatchExport."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "config": {- "bucket_name": "my-production-s3-bucket",- "region": "us-east-1",- "prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- }- # We create an empty schedule so nothing will run and we can pause/unpause as much as we want.- 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,+ s3_batch_export_data,)assert batch_export["paused"] is False@@ -76,26 +58,8 @@ def test_pause_and_unpause_batch_export(client: HttpClient, temporal, organizatidef test_cannot_pause_and_unpause_batch_exports_of_other_organizations(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "config": {- "bucket_name": "my-production-s3-bucket",- "region": "us-east-1",- "prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- }- # We create an empty schedule so nothing will run and we can pause/unpause as much as we want.- batch_export_data = {- "name": "my-production-s3-bucket-destination",- "destination": destination_data,- "interval": "hour",- }-from posthog.api.test.test_team import create_teamfrom posthog.api.test.test_user import create_user@@ -108,7 +72,7 @@ def test_cannot_pause_and_unpause_batch_exports_of_other_organizations(batch_export = create_batch_export_ok(client,team.pk,- batch_export_data,+ s3_batch_export_data,)batch_export_id = batch_export["id"]@@ -142,26 +106,8 @@ def test_cannot_pause_and_unpause_batch_exports_of_other_organizations(def test_pause_and_unpause_are_partitioned_by_team_id(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "config": {- "bucket_name": "my-production-s3-bucket",- "region": "us-east-1",- "prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- }- # We create an empty schedule so nothing will run and we can pause/unpause as much as we want.- batch_export_data = {- "name": "my-production-s3-bucket-destination",- "destination": destination_data,- "interval": "hour",- }-from posthog.api.test.test_team import create_teamother_team = create_team(organization)@@ -169,7 +115,7 @@ def test_pause_and_unpause_are_partitioned_by_team_id(batch_export = create_batch_export_ok(client,team.pk,- batch_export_data,+ s3_batch_export_data,)batch_export_id = batch_export["id"]@@ -200,33 +146,15 @@ def test_pause_and_unpause_are_partitioned_by_team_id(def test_pause_batch_export_that_is_already_paused(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test pausing a BatchExport that is already paused doesn't actually do anything."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "config": {- "bucket_name": "my-production-s3-bucket",- "region": "us-east-1",- "prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- }- # We create an empty schedule so nothing will run and we can pause/unpause as much as we want.- 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,+ s3_batch_export_data,)assert batch_export["paused"] is False@@ -252,33 +180,15 @@ def test_pause_batch_export_that_is_already_paused(def test_unpause_batch_export_that_is_already_unpaused(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test unpausing a BatchExport that is already unpaused doesn't actually do anything."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "config": {- "bucket_name": "my-production-s3-bucket",- "region": "us-east-1",- "prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- }- # We create an empty schedule so nothing will run and we can pause/unpause as much as we want.- 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,+ s3_batch_export_data,)assert batch_export["paused"] is False@@ -294,32 +204,14 @@ def test_unpause_batch_export_that_is_already_unpaused(assert last_updated_at == data["last_updated_at"]-def test_pause_non_existent_batch_export(client: HttpClient, temporal, organization, team, user, aws_s3_integration):+def test_pause_non_existent_batch_export(client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test pausing a BatchExport that doesn't exist."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "config": {- "bucket_name": "my-production-s3-bucket",- "region": "us-east-1",- "prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- }- # We create an empty schedule so nothing will run and we can pause/unpause as much as we want.- 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,+ s3_batch_export_data,)assert batch_export["paused"] is False@@ -333,32 +225,14 @@ def test_pause_non_existent_batch_export(client: HttpClient, temporal, organizatassert resp.status_code == status.HTTP_400_BAD_REQUEST-def test_unpause_can_trigger_a_backfill(client: HttpClient, temporal, organization, team, user, aws_s3_integration):+def test_unpause_can_trigger_a_backfill(client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test unpausing a BatchExport can trigger a backfill."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "config": {- "bucket_name": "my-production-s3-bucket",- "region": "us-east-1",- "prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- }- # We create an empty schedule so nothing will run and we can pause/unpause as much as we want.- 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,+ s3_batch_export_data,)assert batch_export["paused"] is Falsediff --git a/products/batch_exports/backend/tests/api/test_runs.py b/products/batch_exports/backend/tests/api/test_runs.pyindex 89f2ac42d173..feca9dd397c4 100644--- a/products/batch_exports/backend/tests/api/test_runs.py+++ b/products/batch_exports/backend/tests/api/test_runs.py@@ -38,31 +38,13 @@ pytestmark = [def test_can_get_export_runs_for_your_organizations(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)response = create_batch_export_ok(client,team.pk,- batch_export_data,+ s3_batch_export_data,)response = get_batch_export_runs(client, team.pk, response["id"])@@ -70,33 +52,15 @@ def test_can_get_export_runs_for_your_organizations(def test_cannot_get_exports_for_other_organizations(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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",- }-another_organization = create_organization("Another Org")another_user = create_user("[email protected]", "Another Test User", another_organization)client.force_login(user)response = create_batch_export_ok(client,team.pk,- batch_export_data,+ s3_batch_export_data,)client.force_login(another_user)@@ -105,30 +69,12 @@ def test_cannot_get_exports_for_other_organizations(def test_batch_exports_are_partitioned_by_team(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""You shouldn't be able to fetch a BatchExport by id, via a team that itdoesn't belong to."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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",- }-another_team = create_team(organization)# Integrations are team-scoped, so the other team's export needs its own.another_team_integration = Integration.objects.create(@@ -143,7 +89,7 @@ def test_batch_exports_are_partitioned_by_team(batch_export = create_batch_export_ok(client,team.pk,- batch_export_data,+ s3_batch_export_data,)response = get_batch_export(client, another_team.pk, batch_export["id"])@@ -153,7 +99,10 @@ def test_batch_exports_are_partitioned_by_team(batch_export = create_batch_export_ok(client,another_team.pk,- {**batch_export_data, "destination": {**destination_data, "integration": another_team_integration.id}},+ {+ **s3_batch_export_data,+ "destination": {**s3_batch_export_data["destination"], "integration": another_team_integration.id},+ },)response = get_batch_export(client, team.pk, batch_export["id"])@@ -161,25 +110,8 @@ def test_batch_exports_are_partitioned_by_team(@pytest.mark.django_db(transaction=True)-def test_cancelling_a_batch_export_run(client: HttpClient, temporal, organization, team, user, aws_s3_integration):+def test_cancelling_a_batch_export_run(client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""Test cancelling a BatchExportRun."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)with patch("products.batch_exports.backend.temporal.pipeline.producer.Producer.start") as mock_producer_start:@@ -193,7 +125,7 @@ def test_cancelling_a_batch_export_run(client: HttpClient, temporal, organizatiobatch_export = create_batch_export_ok(client,team.pk,- batch_export_data,+ s3_batch_export_data,)batch_export_id = batch_export["id"]diff --git a/products/batch_exports/backend/tests/api/test_test.py b/products/batch_exports/backend/tests/api/test_test.pyindex 1742f9a7d00d..2cda371310df 100644--- a/products/batch_exports/backend/tests/api/test_test.py+++ b/products/batch_exports/backend/tests/api/test_test.py@@ -99,8 +99,8 @@ async def delete_all_from_s3(object_storage_client, bucket_name: str, key_prefixdef object_storage_integration(team, user):"""An s3-compatible Integration pointing at the local object storage used by these tests.- The shared `s3_compatible_integration` fixture points at a fake provider, and its endpoint and- credentials would override the inline ones when running a destination test step.+ The shared `s3_compatible_integration` fixture points at a fake provider, so a destination test+ step configured from it could not reach a real bucket."""return Integration.objects.create(team=team,@@ -125,9 +125,6 @@ def test_can_run_s3_test_step_for_new_destination("bucket_name": bucket_name,"region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "object_storage_root_user",- "aws_secret_access_key": "object_storage_root_password",- "endpoint_url": settings.OBJECT_STORAGE_ENDPOINT,},}@@ -170,9 +167,6 @@ def test_can_run_s3_test_step_for_destination("bucket_name": bucket_name,"region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "object_storage_root_user",- "aws_secret_access_key": "object_storage_root_password",- "endpoint_url": settings.OBJECT_STORAGE_ENDPOINT,},}@@ -205,35 +199,17 @@ def test_can_run_s3_test_step_for_destination(def test_run_test_step_rejects_destination_type_change(- client: HttpClient, temporal, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, organization, team, user, s3_batch_export_data):"""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.+ legacy "S3" type, supply an `endpoint_url` they control, and have the integration's credentials+ tested against that endpoint."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)+ batch_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)malicious_data = {"name": "my-production-s3-bucket-destination",@@ -393,9 +369,6 @@ def test_can_run_s3_test_step_with_additional_fields("bucket_name": bucket_name,"region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "object_storage_root_user",- "aws_secret_access_key": "object_storage_root_password",- "endpoint_url": settings.OBJECT_STORAGE_ENDPOINT,},}diff --git a/products/batch_exports/backend/tests/api/test_update.py b/products/batch_exports/backend/tests/api/test_update.pyindex 1f12a3289ca3..194bdbf39548 100644--- a/products/batch_exports/backend/tests/api/test_update.py+++ b/products/batch_exports/backend/tests/api/test_update.py@@ -56,8 +56,6 @@ def test_can_put_config(client: HttpClient, temporal, encryption_codec, organiza"bucket_name": "my-production-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",},}@@ -91,7 +89,6 @@ def test_can_put_config(client: HttpClient, temporal, encryption_codec, organiza# We should be able to update if we specify all fieldsnew_destination_data = {**destination_data}new_destination_data["config"]["bucket_name"] = "my-new-production-s3-bucket"- new_destination_data["config"]["aws_secret_access_key"] = "new-secret"new_batch_export_data_2: dict[str, t.Any] = {"name": "my-production-s3-bucket-destination","destination": new_destination_data,@@ -119,7 +116,9 @@ def test_can_put_config(client: HttpClient, temporal, encryption_codec, organizadecoded_payload = async_to_sync(encryption_codec.decode)(new_schedule.schedule.action.args)args = json.loads(decoded_payload[0].data)assert args["bucket_name"] == "my-new-production-s3-bucket"- assert args["aws_secret_access_key"] == "new-secret"+ # Credentials are resolved from the integration at run time, never carried in the schedule.+ assert args["integration_id"] == aws_s3_integration.id+ assert args.get("aws_secret_access_key") is None@pytest.mark.parametrize("interval", ["hour", "day"])@@ -136,8 +135,6 @@ def test_can_patch_config("bucket_name": "my-production-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",},}@@ -432,8 +429,6 @@ def test_can_patch_schedule_configuration("bucket_name": "my-production-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",},}@@ -506,16 +501,15 @@ def test_can_patch_schedule_configuration(@pytest.mark.django_db@pytest.mark.parametrize("interval", ["hour", "day"])def test_can_patch_config_with_invalid_old_values(- client: HttpClient, encryption_codec, interval, temporal, organization, team, user+ client: HttpClient, encryption_codec, interval, temporal, organization, team, user, aws_s3_integration):destination_data = {- "type": "S3",+ "type": "AwsS3",+ "integration": aws_s3_integration,"config": {"bucket_name": "my-production-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret","invalid_key": "invalid_value",},}@@ -540,7 +534,8 @@ def test_can_patch_config_with_invalid_old_values(# We should be able to update the destination config, even if there is an invalid config# in the existing keys.new_destination_data = {- "type": "S3",+ "type": "AwsS3",+ "integration": aws_s3_integration.id,"config": {"bucket_name": "my-new-production-s3-bucket","region": "us-east-1",@@ -576,30 +571,12 @@ def test_patch_rejects_destination_type_change(organization,team,user,- aws_s3_integration,+ s3_batch_export_data,bigquery_integration,):"""Assert PATCH cannot change the destination type — callers must delete and recreate."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)+ batch_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)new_destination_data = {"type": "BigQuery",@@ -630,29 +607,11 @@ def test_put_rejects_destination_type_change(organization,team,user,- aws_s3_integration,+ s3_batch_export_data,):"""Assert PUT cannot change the destination type either — same restriction as PATCH."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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)+ batch_export = create_batch_export_ok(client, team.pk, s3_batch_export_data)new_batch_export_data = {"name": "my-production-s3-bucket-destination",@@ -677,33 +636,15 @@ def test_put_rejects_destination_type_change(def test_can_patch_hogql_query(- client: HttpClient, temporal, encryption_codec, organization, team, user, aws_s3_integration+ client: HttpClient, temporal, encryption_codec, organization, team, user, s3_batch_export_data):"""Test we can patch a schema with a HogQL query."""- destination_data = {- "type": "AwsS3",- "integration": aws_s3_integration.id,- "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,+ s3_batch_export_data,)old_schedule = describe_schedule(temporal, batch_export["id"])@@ -779,8 +720,6 @@ def test_patch_returns_error_on_unsupported_hogql_query("bucket_name": "my-production-s3-bucket","region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",},}diff --git a/products/batch_exports/backend/tests/api/test_update_s3.py b/products/batch_exports/backend/tests/api/test_update_s3.pyindex d343008560f9..eb642c6ce58e 100644--- a/products/batch_exports/backend/tests/api/test_update_s3.py+++ b/products/batch_exports/backend/tests/api/test_update_s3.py@@ -16,44 +16,6 @@ pytestmark = []-def _assert_empty_inputs_rejected(client: HttpClient, team_id: int, batch_export_id, destination_type: str) -> None:- response = patch_batch_export(- client,- team_id,- 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']"---def test_updating_legacy_s3_batch_export_validates_empty_inputs(client: HttpClient, temporal, organization, team, user):- """Legacy `S3` rows can no longer be created, but existing ones must remain patchable and validated."""- destination = BatchExportDestination.objects.create(- type="S3",- config={- "bucket_name": "my-s3-bucket",- "region": "us-east-1",- "prefix": "events/",- "aws_access_key_id": "abc123",- "aws_secret_access_key": "secret",- },- )- batch_export = create_batch_export_orm(team, destination)-- client.force_login(user)- _assert_empty_inputs_rejected(client, team.pk, str(batch_export.id), "S3")--_S3_FAMILY_INTEGRATIONS = [("AwsS3", Integration.IntegrationKind.AWS_S3, {"name": "prod-aws", "aws_account_id": "123456789012"}),(@@ -93,7 +55,7 @@ def _create_integration_backed_export(client: HttpClient, team, user, destinatio@pytest.mark.parametrize("destination_type,kind,integration_config", _S3_FAMILY_INTEGRATIONS)@pytest.mark.parametrize("integration_value", [None, "omitted"])-def test_updating_s3_family_batch_export_rejects_removing_integration(+def test_updating_s3_family_batch_export_requires_an_integration(client: HttpClient,temporal,organization,@@ -104,21 +66,25 @@ def test_updating_s3_family_batch_export_rejects_removing_integration(integration_config,integration_value,):- """An integration-backed export can't drop back to inline credentials — whether the caller- sends `integration: null` or omits it entirely (clients re-send the full destination on update).+ """An export can't drop its integration: sending `integration: null` is rejected, and omitting+ it entirely keeps the one already linked."""- _, batch_export = _create_integration_backed_export(client, team, user, destination_type, kind, integration_config)+ integration, batch_export = _create_integration_backed_export(+ client, team, user, destination_type, kind, integration_config+ )- destination: dict = {"type": destination_type, "config": {}}+ destination: dict = {"type": destination_type, "config": {"prefix": "new-prefix/"}}if integration_value is None:destination["integration"] = Noneresponse = patch_batch_export(client, team.pk, batch_export["id"], {"destination": destination})- assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()- assert response.json()["detail"] == (- "Cannot remove the integration from an S3 batch export that uses one. "- "Re-send its `integration` to keep it (or a different one to swap)."- )++ if integration_value is None:+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()+ assert response.json()["detail"] == f"Integration is required for {destination_type} batch exports"+ else:+ assert response.status_code == status.HTTP_200_OK, response.json()+ assert response.json()["destination"]["integration"] == integration.id@pytest.mark.parametrize("destination_type,kind,integration_config", _S3_FAMILY_INTEGRATIONS)@@ -141,8 +107,34 @@ def test_updating_integration_backed_s3_export_allows_config_patch_with_integratassert response.json()["destination"]["integration"] == integration.id-def test_updating_legacy_s3_batch_export_rejects_integration(client: HttpClient, temporal, organization, team, user):- """The legacy `S3` type doesn't support integration-based credentials, so linking one is rejected."""[email protected]("destination_type,kind,integration_config", _S3_FAMILY_INTEGRATIONS)+def test_updating_migrated_s3_batch_export_ignores_credentials_left_in_stored_config(+ client: HttpClient, temporal, organization, team, user, destination_type, kind, integration_config+):+ """Exports migrated onto an integration still hold their old credentials in stored config.++ Those stale values must not make the export unpatchable: only the submitted config is checked+ for credential fields.+ """+ integration, batch_export = _create_integration_backed_export(+ client, team, user, destination_type, kind, integration_config+ )+ destination = BatchExportDestination.objects.get(batchexport__id=batch_export["id"])+ destination.config = {**destination.config, "aws_access_key_id": "stale", "aws_secret_access_key": "stale"}+ destination.save()++ response = patch_batch_export(+ client,+ team.pk,+ batch_export["id"],+ {"destination": {"type": destination_type, "config": {"prefix": "new-prefix/"}, "integration": integration.id}},+ )+ assert response.status_code == status.HTTP_200_OK, response.json()+ assert response.json()["destination"]["config"]["prefix"] == "new-prefix/"+++def test_updating_legacy_s3_batch_export_is_rejected(client: HttpClient, temporal, organization, team, user):+ """The legacy `S3` type has been migrated away and accepts no writes."""destination = BatchExportDestination.objects.create(type="S3",config={@@ -154,21 +146,13 @@ def test_updating_legacy_s3_batch_export_rejects_integration(client: HttpClient,},)batch_export = create_batch_export_orm(team, destination)- integration = Integration.objects.create(- team=team,- kind=Integration.IntegrationKind.AWS_S3,- integration_id="prod-aws",- config={"name": "prod-aws", "aws_account_id": "123456789012"},- sensitive_config={"aws_access_key_id": "key", "aws_secret_access_key": "secret"},- created_by=user,- )client.force_login(user)response = patch_batch_export(client,team.pk,str(batch_export.id),- {"destination": {"type": "S3", "config": {}, "integration": integration.id}},+ {"destination": {"type": "S3", "config": {"prefix": "new-prefix/"}}},)assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()- assert response.json()["detail"] == "S3 destinations do not support integration-based credentials."+ assert "deprecated" in response.json()["detail"]diff --git a/products/batch_exports/frontend/generated/api.schemas.ts b/products/batch_exports/frontend/generated/api.schemas.tsindex 817b692c9bea..2669b426c174 100644--- a/products/batch_exports/frontend/generated/api.schemas.ts+++ b/products/batch_exports/frontend/generated/api.schemas.ts@@ -477,7 +477,7 @@ export interface BatchExportDestinationApi {*/integration?: number | null/**- * ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, Postgres, AwsS3, and S3Compatible destinations; optional for Snowflake and Redshift (inline credentials remain supported); unused for other types.+ * ID of a team-scoped Integration providing credentials, for destinations that authenticate through one. Required for all of those except Snowflake, which still supports inline credentials.* @nullable*/integration_id?: number | null@@ -1374,7 +1374,7 @@ export const AwsS3DestinationRequestApiType = {*/export interface AwsS3DestinationRequestApi {type: AwsS3DestinationRequestApiType- /** ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one. */+ /** ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one. */integration_id: numberconfig: AwsS3DestinationConfigApi}@@ -1391,7 +1391,7 @@ export const S3CompatibleDestinationRequestApiType = {*/export interface S3CompatibleDestinationRequestApi {type: S3CompatibleDestinationRequestApiType- /** ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one. */+ /** ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one. */integration_id: numberconfig: S3CompatibleDestinationConfigApi}diff --git a/products/batch_exports/frontend/generated/api.zod.ts b/products/batch_exports/frontend/generated/api.zod.tsindex 4fba0d4c7c28..fa2d852b397a 100644--- a/products/batch_exports/frontend/generated/api.zod.ts+++ b/products/batch_exports/frontend/generated/api.zod.ts@@ -192,7 +192,7 @@ export const BatchExportsCreateBody = /* @__PURE__ */ zodintegration_id: zod.number().describe(- 'ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -248,7 +248,7 @@ export const BatchExportsCreateBody = /* @__PURE__ */ zodintegration_id: zod.number().describe(- 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -889,7 +889,7 @@ export const BatchExportsUpdateBody = /* @__PURE__ */ zodintegration_id: zod.number().describe(- 'ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -945,7 +945,7 @@ export const BatchExportsUpdateBody = /* @__PURE__ */ zodintegration_id: zod.number().describe(- 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -1341,7 +1341,7 @@ export const BatchExportsPartialUpdateBody = /* @__PURE__ */ zodintegration_id: zod.number().describe(- 'ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -1397,7 +1397,7 @@ export const BatchExportsPartialUpdateBody = /* @__PURE__ */ zodintegration_id: zod.number().describe(- 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -1984,7 +1984,7 @@ export const BatchExportsPauseCreateBody = /* @__PURE__ */ zod.number().nullish().describe(- 'ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, Postgres, AwsS3, and S3Compatible destinations; optional for Snowflake and Redshift (inline credentials remain supported); unused for other types.'+ 'ID of a team-scoped Integration providing credentials, for destinations that authenticate through one. Required for all of those except Snowflake, which still supports inline credentials.'),}).describe(@@ -2429,7 +2429,7 @@ export const BatchExportsRunTestStepCreateBody = /* @__PURE__ */ zod.number().nullish().describe(- 'ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, Postgres, AwsS3, and S3Compatible destinations; optional for Snowflake and Redshift (inline credentials remain supported); unused for other types.'+ 'ID of a team-scoped Integration providing credentials, for destinations that authenticate through one. Required for all of those except Snowflake, which still supports inline credentials.'),}).describe(@@ -2863,7 +2863,7 @@ export const BatchExportsUnpauseCreateBody = /* @__PURE__ */ zod.number().nullish().describe(- 'ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, Postgres, AwsS3, and S3Compatible destinations; optional for Snowflake and Redshift (inline credentials remain supported); unused for other types.'+ 'ID of a team-scoped Integration providing credentials, for destinations that authenticate through one. Required for all of those except Snowflake, which still supports inline credentials.'),}).describe(@@ -3318,7 +3318,7 @@ export const BatchExportsRunTestStepNewCreateBody = /* @__PURE__ */ zod.number().nullish().describe(- 'ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, Postgres, AwsS3, and S3Compatible destinations; optional for Snowflake and Redshift (inline credentials remain supported); unused for other types.'+ 'ID of a team-scoped Integration providing credentials, for destinations that authenticate through one. Required for all of those except Snowflake, which still supports inline credentials.'),}).describe(diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 0d8bb7d0302d..085080f2bfbb 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -11127,7 +11127,7 @@ export namespace Schemas {*/export interface AwsS3DestinationRequest {type: AwsS3DestinationRequestType;- /** ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one. */+ /** ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one. */integration_id: number;config: AwsS3DestinationConfig;}@@ -12118,7 +12118,7 @@ export namespace Schemas {*/integration?: number | null;/**- * ID of a team-scoped Integration providing credentials. Required when creating Databricks, AzureBlob, BigQuery, Postgres, AwsS3, and S3Compatible destinations; optional for Snowflake and Redshift (inline credentials remain supported); unused for other types.+ * ID of a team-scoped Integration providing credentials, for destinations that authenticate through one. Required for all of those except Snowflake, which still supports inline credentials.* @nullable*/integration_id?: number | null;@@ -13082,7 +13082,7 @@ export namespace Schemas {*/export interface S3CompatibleDestinationRequest {type: S3CompatibleDestinationRequestType;- /** ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one. */+ /** ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one. */integration_id: number;config: S3CompatibleDestinationConfig;}diff --git a/services/mcp/src/generated/batch_exports/api.ts b/services/mcp/src/generated/batch_exports/api.tsindex 784c05ad5a5c..b906a9f6cea1 100644--- a/services/mcp/src/generated/batch_exports/api.ts+++ b/services/mcp/src/generated/batch_exports/api.ts@@ -208,7 +208,7 @@ export const BatchExportsCreateBody = () => zodintegration_id: zod.number().describe(- 'ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -263,7 +263,7 @@ export const BatchExportsCreateBody = () => zodintegration_id: zod.number().describe(- 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -660,7 +660,7 @@ export const BatchExportsPartialUpdateBody = () => zodintegration_id: zod.number().describe(- 'ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one.'),config: zod.object({@@ -715,7 +715,7 @@ export const BatchExportsPartialUpdateBody = () => zodintegration_id: zod.number().describe(- 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one.'+ 'ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one.'),config: zod.object({diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.jsonindex 4ecfb919d4c9..822c47892d34 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json@@ -265,7 +265,7 @@"type": "object"},"integration_id": {- "description": "ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.",+ "description": "ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one.","type": "number"},"type": {@@ -334,7 +334,7 @@"type": "object"},"integration_id": {- "description": "ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one.",+ "description": "ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one.","type": "number"},"type": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.jsonindex 83d87c2497b0..35d52a0192c0 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json@@ -264,7 +264,7 @@"type": "object"},"integration_id": {- "description": "ID of an aws-s3-kind Integration providing AWS credentials. Required when creating a batch export. Use the integrations-list MCP tool to find one.",+ "description": "ID of an aws-s3-kind Integration providing AWS credentials. Use the integrations-list MCP tool to find one.","type": "number"},"type": {@@ -333,7 +333,7 @@"type": "object"},"integration_id": {- "description": "ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Required when creating a batch export. Use the integrations-list MCP tool to find one.",+ "description": "ID of an s3-compatible-kind Integration providing credentials and the provider endpoint URL. Use the integrations-list MCP tool to find one.","type": "number"},"type": {