: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(data-warehouse): implement the synthesia import source (#111866)
Tom Owers8d54a1effad2
diff --git a/frontend/public/services/synthesia.png b/frontend/public/services/synthesia.pngnew file mode 100644index 000000000000..ac5c15958ef0Binary files /dev/null and b/frontend/public/services/synthesia.png differdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.mdindex 1996f4a3afa5..ea78eb63aca7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md@@ -754,6 +754,7 @@ the row lists both.| survicate | HTTP | requests | ✅ || svix | HTTP | requests | ✅ || swarmia | HTTP | requests | ✅ |+| synthesia | HTTP | requests | ✅ || systeme | HTTP | requests | ✅ || taboola | HTTP | requests | ✅ || tailscale | HTTP | requests | ✅ |@@ -1433,7 +1434,6 @@ doesn't conflict with concurrent PRs.- svix- swan- swonkie-- synthesia- tackle_io- talkdesk- tanadiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/sample_scrub.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/sample_scrub.pyindex d1965cdb0db3..189a6a9e9c85 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/sample_scrub.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/sample_scrub.py@@ -54,6 +54,8 @@ REDACT_FIELD_NAMES: frozenset[str] = frozenset(# name and would otherwise reach captured samples raw (the source's own `redact_fields`# strips it from synced rows, but that runs after, not before, sample capture)."imap_password",+ # Synthesia's webhooks endpoint returns each webhook signing secret under this key.+ "secret",})diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_http_sampling.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_http_sampling.pyindex 5b8921260b81..ca40294968d6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_http_sampling.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/test/test_http_sampling.py@@ -497,6 +497,12 @@ def test_scrub_body_redacts_nested_json_secrets():assert out["data"]["page"] == 2+def test_scrub_body_redacts_webhook_signing_secret():+ out = _scrub_body('{"webhooks": [{"id": "hook-1", "secret": "signing-secret"}]}')+ assert isinstance(out, dict)+ assert out["webhooks"][0]["secret"] == "REDACTED"++def test_scrub_body_passes_through_non_json_string():out = _scrub_body("just a string")assert isinstance(out, str)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/synthesia.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/synthesia.pyindex 16224b841cd4..2987388d8410 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/synthesia.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/synthesia.py@@ -6,4 +6,4 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common imp@config.configclass SynthesiaSourceConfig(config.Config):- pass+ api_key: strdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/canonical_descriptions.pynew file mode 100644index 000000000000..0a80e7540f4e--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/canonical_descriptions.py@@ -0,0 +1,44 @@+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)++CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {+ "videos": {+ "description": "Videos created through the Synthesia API or Studio that the API key can access.",+ "docs_url": "https://docs.synthesia.io/reference/list-videos",+ "columns": {+ "id": "Unique video identifier.",+ "createdAt": "Video creation time as a Unix timestamp.",+ "lastUpdatedAt": "Time of the last video update.",+ "title": "Video title displayed on its share page.",+ "description": "Video description displayed on its share page.",+ "status": "Video processing or review status.",+ "visibility": "Whether the video share page is public or private.",+ "callbackId": "Identifier supplied to link the video to its creation request.",+ "test": "Whether the video uses test mode with a watermark.",+ },+ },+ "templates": {+ "description": "Synthesia and workspace templates available to the API key, including their variables.",+ "docs_url": "https://docs.synthesia.io/reference/list-templates",+ "columns": {+ "id": "Unique template identifier.",+ "title": "Template title.",+ "description": "Template description.",+ "variables": "Variables accepted when creating a video from this template.",+ "createdAt": "Template creation time.",+ "lastUpdatedAt": "Time of the last template update.",+ },+ },+ "webhooks": {+ "description": "Active webhook subscriptions for the account that owns the API key. Signing secrets are excluded.",+ "docs_url": "https://docs.synthesia.io/reference/list-webhooks",+ "columns": {+ "id": "Unique webhook identifier.",+ "url": "Destination URL for webhook notifications.",+ "status": "Webhook status.",+ "createdAt": "Webhook creation time.",+ "lastUpdatedAt": "Time of the last webhook update.",+ },+ },+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/settings.pynew file mode 100644index 000000000000..ce3f39af45b5--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/settings.py@@ -0,0 +1,13 @@+BASE_URL = "https://api.synthesia.io"+PAGE_SIZE = 100++ENDPOINTS = {+ "videos": "videos",+ "templates": "templates",+ "webhooks": "webhooks",+}++AUTH_ERROR = (+ "Synthesia rejected the API key. Create an active key with the Legacy (v2) scope in Developers > API keys. "+ "API access requires a Creator or Enterprise plan."+)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/source.pyindex c71afdbc30be..f27b0abaf4bb 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/source.py@@ -1,28 +1,117 @@from typing import cast-from products.warehouse_sources.backend.facade.source_config import DataWarehouseSourceCategory, SourceConfig-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource+from products.warehouse_sources.backend.facade.source_config import (+ DataWarehouseSourceCategory,+ ReleaseStatus,+ SourceConfig,+ SourceFieldInputConfig,+ SourceFieldInputConfigType,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (+ SourceSchema,+ build_endpoint_schemas,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponsefrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.synthesia import (SynthesiaSourceConfig,)+from products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.canonical_descriptions import (+ CANONICAL_DESCRIPTIONS,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.settings import AUTH_ERROR, ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.synthesia import (+ SynthesiaResumeConfig,+ synthesia_source,+ validate_credentials,+)from products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.register-class SynthesiaSource(SimpleSource[SynthesiaSourceConfig]):+class SynthesiaSource(ResumableSource[SynthesiaSourceConfig, SynthesiaResumeConfig]):+ lists_tables_without_credentials = True+ supported_versions = ("v2",)+ default_version = "v2"+ api_docs_url = "https://docs.synthesia.io/reference/video-api-introduction"+@propertydef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.SYNTHESIA+ def get_non_retryable_errors(self) -> dict[str, str | None]:+ return {"401 Client Error": AUTH_ERROR, "403 Client Error": AUTH_ERROR}++ def get_canonical_descriptions(self) -> CanonicalDescriptions:+ return CANONICAL_DESCRIPTIONS++ def get_schemas(+ self,+ config: SynthesiaSourceConfig,+ team_id: int,+ with_counts: bool = False,+ names: list[str] | None = None,+ force_refresh: bool = False,+ api_version: str | None = None,+ ) -> list[SourceSchema]:+ return build_endpoint_schemas(ENDPOINTS, {}, names)++ def validate_credentials(+ self,+ config: SynthesiaSourceConfig,+ team_id: int,+ schema_name: str | None = None,+ api_version: str | None = None,+ ) -> tuple[bool, str | None]:+ return validate_credentials(config.api_key, self.resolve_api_version(api_version), schema_name or "videos")++ def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[SynthesiaResumeConfig]:+ return ResumableSourceManager(inputs, SynthesiaResumeConfig)++ def source_for_pipeline(+ self,+ config: SynthesiaSourceConfig,+ resumable_source_manager: ResumableSourceManager[SynthesiaResumeConfig],+ inputs: SourceInputs,+ ) -> SourceResponse:+ return synthesia_source(+ api_key=config.api_key,+ api_version=self.resolve_api_version(inputs.api_version),+ endpoint=inputs.schema_name,+ team_id=inputs.team_id,+ job_id=inputs.job_id,+ resumable_source_manager=resumable_source_manager,+ )+@propertydef get_source_config(self) -> SourceConfig:return SourceConfig(name=ExternalDataSourceType.SYNTHESIA,category=DataWarehouseSourceCategory.PRODUCTIVITY,label="Synthesia",+ caption=(+ "Create an API key in Synthesia Studio under Developers > API keys. "+ "Select the Legacy (v2) scope. A Creator or Enterprise plan is required."+ ),iconPath="/static/services/synthesia.png",keywords=["video", "ai video", "avatar", "synthesia"],- fields=cast(list[FieldType], []),- unreleasedSource=True,+ fields=cast(+ list[FieldType],+ [+ SourceFieldInputConfig(+ name="api_key",+ label="API key",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="",+ secret=True,+ )+ ],+ ),+ releaseStatus=ReleaseStatus.ALPHA,)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/synthesia.py b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/synthesia.pynew file mode 100644index 000000000000..704436fa498c--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/synthesia.py@@ -0,0 +1,105 @@+from typing import Any++from posthog.dataclasses import frozen++from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (+ RESTAPIConfig,+ rest_api_resource,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import APIKeyAuth+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import EndpointResource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import schema_for_resource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse+from products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.settings import (+ AUTH_ERROR,+ BASE_URL,+ ENDPOINTS,+ PAGE_SIZE,+)+++@frozen+class SynthesiaResumeConfig:+ next_offset: int+++def remove_webhook_secret(row: dict[str, Any]) -> dict[str, Any]:+ # Signing secrets must not become queryable warehouse columns.+ return {key: value for key, value in row.items() if key != "secret"}+++def validate_credentials(api_key: str, api_version: str, endpoint: str = "videos") -> tuple[bool, str | None]:+ path = schema_for_resource(ENDPOINTS, endpoint)+ with make_tracked_session() as session:+ response = session.get(+ f"{BASE_URL}/{api_version}/{path}",+ params={"limit": 1},+ auth=APIKeyAuth(api_key=api_key),+ timeout=30,+ )+ if response.status_code in (401, 403):+ return False, AUTH_ERROR+ response.raise_for_status()+ return True, None+++def synthesia_source(+ api_key: str,+ api_version: str,+ endpoint: str,+ team_id: int,+ job_id: str,+ resumable_source_manager: ResumableSourceManager[SynthesiaResumeConfig],+) -> SourceResponse:+ path = schema_for_resource(ENDPOINTS, endpoint)+ resource_config: EndpointResource = {+ "name": endpoint,+ "table_name": endpoint,+ "write_disposition": "replace",+ "endpoint": {+ "path": path,+ "data_selector": endpoint,+ "data_selector_required": True,+ "params": {"limit": PAGE_SIZE, "offset": 0},+ },+ }+ if endpoint == "webhooks":+ resource_config["data_map"] = remove_webhook_secret++ config: RESTAPIConfig = {+ "client": {+ "base_url": f"{BASE_URL}/{api_version}/",+ "request_timeout": (10.0, 60.0),+ "auth": {"type": "api_key", "name": "Authorization", "api_key": api_key, "location": "header"},+ "paginator": {+ "type": "cursor",+ "cursor_path": "nextOffset",+ "cursor_param": "offset",+ "raise_on_repeated_cursor": True,+ },+ },+ "resources": [resource_config],+ }+ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None++ def save_checkpoint(state: dict[str, Any] | None) -> None:+ if state is not None and state.get("cursor") is not None:+ resumable_source_manager.save_state(SynthesiaResumeConfig(next_offset=int(state["cursor"])))++ resource = rest_api_resource(+ config,+ team_id,+ job_id,+ db_incremental_field_last_value=None,+ resume_hook=save_checkpoint,+ initial_paginator_state={"cursor": resume.next_offset} if resume else None,+ )+ return SourceResponse(+ name=endpoint,+ items=lambda: resource,+ primary_keys=["id"],+ sort_mode=None,+ on_complete=resumable_source_manager.clear_state,+ )diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/tests/test_synthesia.py b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/tests/test_synthesia.pynew file mode 100644index 000000000000..aae35f9a952b--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/tests/test_synthesia.py@@ -0,0 +1,165 @@+import json+from collections.abc import Iterable+from typing import Any, cast+from urllib.parse import parse_qs, urlsplit++import pytest+from unittest.mock import MagicMock, patch++from requests import HTTPError, PreparedRequest, Response++from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import UnknownResourceError+from products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.source import SynthesiaSource+from products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.synthesia import (+ SynthesiaResumeConfig,+ synthesia_source,+ validate_credentials,+)+++def make_response(body: dict[str, Any], status: int = 200) -> Response:+ response = Response()+ response.status_code = status+ response.reason = {401: "Unauthorized", 403: "Forbidden"}.get(status, "Test response")+ response._content = json.dumps(body).encode()+ response.headers["Content-Type"] = "application/json"+ response.url = "https://api.synthesia.io/v2/videos"+ return response+++def manager() -> MagicMock:+ result = MagicMock(spec=ResumableSourceManager)+ result.can_resume.return_value = False+ return result++[email protected]("endpoint", ["videos", "templates", "webhooks"])+def test_pagination_uses_returned_offset_and_raw_auth(endpoint: str, manager: MagicMock) -> None:+ rows = [{"id": "item-1", "createdAt": 1700000000}, {"id": "item-2", "createdAt": 1700000001}]+ responses = [make_response({endpoint: [rows[0]], "nextOffset": 37}), make_response({endpoint: [rows[1]]})]+ with patch("requests.Session.send", side_effect=responses) as send:+ result = synthesia_source("fake-api-key", "v2", endpoint, 1, "job", manager)+ pages = list(cast(Iterable[list[dict[str, Any]]], result.items()))++ assert pages == [[rows[0]], [rows[1]]]+ for call, offset in zip(send.call_args_list, ["0", "37"], strict=True):+ request: PreparedRequest = call.args[0]+ assert call.kwargs["timeout"] == (10.0, 60.0)+ assert request.method == "GET"+ assert request.headers["Authorization"] == "fake-api-key"+ url = urlsplit(cast(str, request.url))+ assert (url.scheme, url.netloc, url.path) == ("https", "api.synthesia.io", f"/v2/{endpoint}")+ assert parse_qs(url.query) == {"limit": ["100"], "offset": [offset]}+ manager.save_state.assert_called_once_with(SynthesiaResumeConfig(next_offset=37))+ manager.clear_state.assert_not_called()+ assert result.on_complete is not None+ result.on_complete()+ manager.clear_state.assert_called_once()+++ "body",+ [+ {"videos": []},+ {"videos": [{"id": "last"}]},+ {"videos": [{"id": "last"}], "nextOffset": None},+ {"videos": [{"id": "last"}], "nextOffset": 0},+ ],+)+def test_terminal_page_stops_without_saving_cursor(body: dict[str, Any], manager: MagicMock) -> None:+ with patch("requests.Session.send", return_value=make_response(body)) as send:+ result = synthesia_source("fake-api-key", "v2", "videos", 1, "job", manager)+ pages = list(cast(Iterable[list[dict[str, Any]]], result.items()))+ assert [row for page in pages for row in page] == body["videos"]+ send.assert_called_once()+ manager.save_state.assert_not_called()++[email protected]("saved_offset", [None, 123])+def test_resume_starts_at_saved_offset(saved_offset: int | None, manager: MagicMock) -> None:+ manager.can_resume.return_value = True+ manager.load_state.return_value = SynthesiaResumeConfig(next_offset=saved_offset) if saved_offset else None+ with patch("requests.Session.send", return_value=make_response({"videos": []})) as send:+ result = synthesia_source("fake-api-key", "v2", "videos", 1, "job", manager)+ list(cast(Iterable[Any], result.items()))+ query = parse_qs(urlsplit(send.call_args.args[0].url).query)+ assert query["offset"] == [str(saved_offset or 0)]+++def test_repeated_offset_fails_instead_of_looping(manager: MagicMock) -> None:+ manager.can_resume.return_value = True+ manager.load_state.return_value = SynthesiaResumeConfig(next_offset=12)+ with patch("requests.Session.send", return_value=make_response({"videos": [{"id": "v"}], "nextOffset": 12})):+ result = synthesia_source("fake-api-key", "v2", "videos", 1, "job", manager)+ with pytest.raises(ValueError, match="repeated cursor"):+ list(cast(Iterable[Any], result.items()))+ manager.save_state.assert_not_called()+++def test_webhook_signing_secrets_are_not_imported(manager: MagicMock) -> None:+ row = {"id": "hook-1", "secret": "fake-signing-secret", "url": "https://example.com/hook", "status": "active"}+ with patch("requests.Session.send", return_value=make_response({"webhooks": [row]})):+ result = synthesia_source("fake-api-key", "v2", "webhooks", 1, "job", manager)+ pages = list(cast(Iterable[Any], result.items()))+ assert pages == [[{"id": "hook-1", "url": "https://example.com/hook", "status": "active"}]]++[email protected]("status", [200, 401, 403, 404, 429, 500])+def test_credential_status_mapping(status: int) -> None:+ with patch("requests.Session.send", return_value=make_response({"videos": []}, status)) as send:+ if status in (200, 401, 403):+ valid, message = validate_credentials("fake-api-key", "v2")+ assert valid is (status == 200)+ if status == 200:+ assert message is None+ else:+ assert message is not None and "Legacy (v2)" in message+ else:+ with pytest.raises(HTTPError):+ validate_credentials("fake-api-key", "v2")+ send.assert_called_once()+ request = send.call_args.args[0]+ assert request.headers["Authorization"] == "fake-api-key"+ assert parse_qs(urlsplit(request.url).query) == {"limit": ["1"]}++[email protected]("status", [401, 403])+def test_sync_auth_errors_are_terminal_and_mapped(status: int, manager: MagicMock) -> None:+ body = {"context": "User is not authenticated", "error": "Forbidden"}+ with patch("requests.Session.send", return_value=make_response(body, status)) as send:+ result = synthesia_source("fake-api-key", "v2", "videos", 1, "job", manager)+ with pytest.raises(HTTPError) as error:+ list(cast(Iterable[Any], result.items()))+ send.assert_called_once()+ messages = [+ message+ for pattern, message in SynthesiaSource().get_non_retryable_errors().items()+ if pattern in str(error.value)+ ]+ assert len(messages) == 1+ assert messages[0] is not None and "Legacy (v2)" in messages[0]++[email protected]("status", [429, 503])+def test_sync_transient_errors_retry(status: int, manager: MagicMock) -> None:+ responses = [make_response({"error": "temporary"}, status), make_response({"videos": [{"id": "v"}]})]+ with patch("requests.Session.send", side_effect=responses) as send, patch("time.sleep"):+ result = synthesia_source("fake-api-key", "v2", "videos", 1, "job", manager)+ assert list(cast(Iterable[Any], result.items())) == [[{"id": "v"}]]+ assert send.call_count == 2+++def test_unknown_endpoint_fails_before_request(manager: MagicMock) -> None:+ with patch("requests.Session.send") as send:+ with pytest.raises(UnknownResourceError):+ synthesia_source("fake-api-key", "v2", "unknown", 1, "job", manager)+ send.assert_not_called()+++def test_missing_list_fails_instead_of_replacing_table_with_empty_data(manager: MagicMock) -> None:+ with patch("requests.Session.send", return_value=make_response({"unexpected": []})):+ result = synthesia_source("fake-api-key", "v2", "videos", 1, "job", manager)+ with pytest.raises(ValueError):+ list(cast(Iterable[Any], result.items()))diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/tests/test_synthesia_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/tests/test_synthesia_source.pynew file mode 100644index 000000000000..aab2dfdbe236--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/synthesia/tests/test_synthesia_source.py@@ -0,0 +1,56 @@+from urllib.parse import urlsplit++import pytest+from unittest.mock import MagicMock, patch++from requests import Response++from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.synthesia import (+ SynthesiaSourceConfig,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.source import SynthesiaSource+from products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.synthesia import SynthesiaResumeConfig++[email protected]("schema_name", [None, "templates", "webhooks"])+def test_credential_probe_uses_selected_endpoint(schema_name: str | None) -> None:+ response = Response()+ response.status_code = 200+ response._content = b"{}"+ with patch("requests.Session.send", return_value=response) as send:+ result = SynthesiaSource().validate_credentials(+ SynthesiaSourceConfig(api_key="fake-api-key"), team_id=1, schema_name=schema_name+ )+ assert result == (True, None)+ assert urlsplit(send.call_args.args[0].url).path == f"/v2/{schema_name or 'videos'}"+++def test_resumable_source_manager_uses_synthesia_checkpoint() -> None:+ manager = SynthesiaSource().get_resumable_source_manager(MagicMock())++ assert isinstance(manager, ResumableSourceManager)+ assert manager._data_class is SynthesiaResumeConfig+++def test_source_for_pipeline_plumbs_sync_context() -> None:+ config = SynthesiaSourceConfig(api_key="fake-api-key")+ inputs = MagicMock(schema_name="templates", team_id=2, job_id="job-id", api_version=None)+ manager = MagicMock(spec=ResumableSourceManager)+ response = MagicMock()++ with patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.synthesia.source.synthesia_source",+ return_value=response,+ ) as source:+ result = SynthesiaSource().source_for_pipeline(config, manager, inputs)++ assert result is response+ source.assert_called_once_with(+ api_key="fake-api-key",+ api_version="v2",+ endpoint="templates",+ team_id=2,+ job_id="job-id",+ resumable_source_manager=manager,+ )diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_catalog_invariants.py b/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_catalog_invariants.pyindex ad5fd1620b7f..d297f2834862 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_catalog_invariants.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_catalog_invariants.py@@ -73,7 +73,6 @@ SOURCES_WITHOUT_AN_ICON_FILE = {"Roark","ScaleAI","Skyvern",- "Synthesia","TerraApi","TriggerDev","TwelveLabs",