: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): add elevenlabs models, workspace and tool tables (#115315)
Tom Owers1c952b64cce0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex d060c9c0a258..baa323dca6b9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -2852,9 +2852,9 @@ Today (4): `agents`, `conversations`, `history`, `voices`Diffed against: <https://api.elevenlabs.io/openapi.json>- [ ] `/v1/usage/character-stats` — the vendor's headline usage metric — character/credit consumption over time, broken down by voice, model and workspace user (high)-- [ ] `/v1/models` — lookup table resolving the model_id carried on history items and conversations (high)-- [ ] `/v1/workspace/members (and /v1/workspace/groups)` — lookup resolving the workspace user ids attached to history, conversations and usage rows (high)-- [ ] `/v1/convai/tools and /v1/convai/tools/{tool_id}/executions` — agent tool catalog plus per-execution records — the analytical detail behind agent conversations (medium)+- [x] `/v1/models` — lookup table resolving the model_id carried on history items and conversations (high)+- [x] `/v1/workspace/members (and /v1/workspace/groups)` — lookup resolving the workspace user ids attached to history, conversations and usage rows (high)+- [x] `/v1/convai/tools and /v1/convai/tools/{tool_id}/executions` — agent tool catalog plus per-execution records — the analytical detail behind agent conversations (medium)- [ ] `/v1/convai/phone-numbers` — lookup resolving the phone number a Conversational AI call came in on (medium)- [ ] `/v1/convai/batch-calling/workspace` — batch calling jobs, the campaign-level grouping over outbound conversations (medium)- [ ] `/v1/user/subscription` — plan quota and current-period usage, needed to turn character stats into utilization (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/canonical_descriptions.pyindex eb04b6fde8ea..bb07899337d5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/canonical_descriptions.py@@ -89,4 +89,74 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"updated_at_unix_secs": "Last update time of the ticket, in Unix seconds.",},},+ "models": {+ "description": "Speech models available to your account. One row per model. Resolves the model_id on history items and conversations.",+ "docs_url": "https://elevenlabs.io/docs/api-reference/models/list",+ "columns": {+ "model_id": "Unique identifier for the model.",+ "name": "Display name of the model.",+ "description": "Description of the model.",+ "can_do_text_to_speech": "Whether the model can do text-to-speech.",+ "can_do_voice_conversion": "Whether the model can do voice conversion.",+ "token_cost_factor": "Cost factor applied to usage of the model.",+ "maximum_text_length_per_request": "Maximum number of input text characters accepted per request.",+ "languages": "Languages the model supports.",+ "model_rates": "Rates charged for the model.",+ "concurrency_group": "Concurrency group of the model.",+ },+ },+ "workspace_members": {+ "description": "Members of your workspace, including locked members. Service accounts are excluded. One row per member.",+ "docs_url": "https://elevenlabs.io/docs/api-reference/workspace/members/list",+ "columns": {+ "user_id": "Unique identifier for the workspace member.",+ "email": "Email address of the workspace member.",+ "first_name": "First name of the workspace member, if available.",+ "seat_type": "Seat type (role) of the workspace member.",+ "is_owner": "Whether the member is the workspace owner.",+ "is_locked": "Whether the member's account is locked in this workspace.",+ },+ },+ "workspace_groups": {+ "description": "User groups in your workspace. One row per group.",+ "docs_url": "https://elevenlabs.io/docs/api-reference/workspace/groups/list",+ "columns": {+ "id": "Unique identifier for the group.",+ "name": "Display name of the group.",+ "members": "Identifiers of the users in the group.",+ "permissions": "Permissions granted to the group.",+ "group_usage_limit": "Usage limit of the group, or 'unlimited'.",+ "character_count": "Characters used by the group.",+ "is_scim_synced": "Whether the group is synced from an identity provider through SCIM.",+ },+ },+ "tools": {+ "description": "Conversational AI tools available in your workspace. One row per tool.",+ "docs_url": "https://elevenlabs.io/docs/api-reference/tools/list",+ "columns": {+ "id": "Unique identifier for the tool.",+ "tool_config": "Configuration of the tool, including its name, type, and parameters.",+ "access_info": "Ownership and access metadata for the tool.",+ "usage_stats": "Aggregate call count and average latency of the tool.",+ },+ },+ "tool_executions": {+ "description": "Executions of Conversational AI tools during agent conversations. One row per tool call.",+ "docs_url": "https://elevenlabs.io/docs/api-reference/tools/get-executions",+ "columns": {+ "id": "Unique identifier for the execution.",+ "tool_id": "Identifier of the tool that was executed.",+ "tool_request_id": "Request (call) identifier of the execution.",+ "conversation_id": "Identifier of the conversation in which the tool was executed.",+ "agent_id": "Identifier of the agent that ran the tool.",+ "branch_id": "Identifier of the agent branch, if the agent has branches.",+ "timestamp": "Time of the execution, in Unix seconds.",+ "latency_secs": "Duration of the execution, in seconds.",+ "is_error": "Whether the execution failed.",+ "request_payload": "Parameters the model sent to the tool, as a JSON string.",+ "response_payload": "Response the tool returned.",+ "error_message": "Error message, if the execution failed.",+ "error_type": "Error category, if the execution failed.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/elevenlabs.py b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/elevenlabs.pyindex 9265159f17e2..d80bb71548dd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/elevenlabs.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/elevenlabs.py@@ -1,6 +1,7 @@import dataclasses+from collections.abc import Mappingfrom datetime import UTC, date, datetime-from typing import Any, Optional+from typing import Any, Optional, castfrom requests import Request, Response@@ -9,7 +10,16 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resRESTAPIConfig,rest_api_resource,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import BasePaginator+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ FanoutEndpointLike,+ build_dependent_resource,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (+ BasePaginator,+ SinglePagePaginator,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfigfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse@@ -19,6 +29,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.elevenlabs)ELEVENLABS_BASE_URL = "https://api.elevenlabs.io"+REDACTED = "[REDACTED]"+# Webhook tools can carry literal credentials in their configured request headers, and executions echo+# the headers that were sent. Warehouse readers must not be able to read them back.+SECRET_BEARING_ENDPOINTS = frozenset({"tools", "tool_executions"})@dataclasses.dataclass@@ -52,6 +66,24 @@ def _to_unix_seconds(value: Any) -> int:return int(value)+def _redact_header_values(headers: Any) -> Any:+ if not isinstance(headers, dict):+ return headers+ # Non-string values are secret, env var, or dynamic variable references, not the secret itself.+ return {name: REDACTED if isinstance(value, str) else value for name, value in headers.items()}+++def _redact_tool_secrets(row: dict[str, Any]) -> dict[str, Any]:+ tool_config = row.get("tool_config")+ api_schema = tool_config.get("api_schema") if isinstance(tool_config, dict) else None+ if isinstance(api_schema, dict) and "request_headers" in api_schema:+ api_schema["request_headers"] = _redact_header_values(api_schema["request_headers"])+ details = row.get("tool_call_details")+ if isinstance(details, dict) and "headers" in details:+ details["headers"] = _redact_header_values(details["headers"])+ return row++def _build_params(config: ElevenLabsEndpointConfig,should_use_incremental_field: bool,@@ -64,7 +96,7 @@ def _build_params(API keeps the time-window filter alongside the cursor), so pagination terminates at `has_more`rather than re-walking full history each incremental run."""- params: dict[str, Any] = {"page_size": config.page_size}+ params: dict[str, Any] = {} if config.page_size is None else {"page_size": config.page_size}params.update(config.extra_params)if (@@ -130,6 +162,26 @@ class ElevenLabsCursorPaginator(BasePaginator):self._has_next_page = True+def _paginator(config: ElevenLabsEndpointConfig) -> BasePaginator:+ if config.cursor_param is None or config.cursor_response_key is None:+ return SinglePagePaginator()+ return ElevenLabsCursorPaginator(config.cursor_param, config.cursor_response_key)+++def _client_config(api_key: str, paginator: BasePaginator) -> ClientConfig:+ return {+ "base_url": ELEVENLABS_BASE_URL,+ # Only the non-secret Accept header is set here; the key is injected via `auth` so it's+ # redacted from logs and captured HTTP samples.+ "headers": {"Accept": "application/json"},+ "auth": {"type": "api_key", "api_key": api_key, "name": "xi-api-key", "location": "header"},+ "paginator": paginator,+ # Redact the key and refuse redirects: requests preserves the custom `xi-api-key` header+ # across a cross-origin 3xx, so following one could replay the key to another origin.+ "session": make_tracked_session(redact_values=(api_key,), allow_redirects=False),+ }++def validate_credentials(api_key: str, schema_name: Optional[str] = None) -> tuple[bool, str | None]:"""Probe the API key. 200 => valid. 401 => invalid key. 403 => valid key missing a scope.@@ -142,9 +194,12 @@ def validate_credentials(api_key: str, schema_name: Optional[str] = None) -> tupvalidation fails rather than saving an unverified key as valid — the user can retry a transient blip."""config = ELEVENLABS_ENDPOINTS.get(schema_name) if schema_name else None+ # A fan-out child's path needs a parent id, and the parent listing needs the same permission.+ if config is not None and config.fanout is not None:+ config = ELEVENLABS_ENDPOINTS[config.fanout.parent_name]probe_path = config.path if config else "/v1/user"# Bake the probe's page_size into the URL: validate_via_probe issues a bare GET with no params.- url = f"{ELEVENLABS_BASE_URL}{probe_path}{'?page_size=1' if config else ''}"+ url = f"{ELEVENLABS_BASE_URL}{probe_path}{'?page_size=1' if config and config.page_size else ''}"# Don't follow redirects: requests preserves the custom `xi-api-key` header across a cross-origin# 3xx, so a redirect off the fixed API host could replay the key to another origin.@@ -192,18 +247,55 @@ def elevenlabs_source(params = _build_params(config, should_use_incremental_field, db_incremental_field_last_value, incremental_field)+ partition_kwargs: dict[str, Any] = {}+ if config.partition_key is not None:+ partition_kwargs = {+ "partition_count": 1,+ "partition_size": 1,+ "partition_mode": "datetime",+ "partition_format": "month",+ "partition_keys": [config.partition_key],+ }++ if config.fanout is not None:+ parent_config = ELEVENLABS_ENDPOINTS[config.fanout.parent_name]+ resource = cast(+ Resource,+ build_dependent_resource(+ # Both fan-out configs set page_size; only unpaginated endpoints leave it None.+ endpoint_configs=cast(Mapping[str, FanoutEndpointLike], ELEVENLABS_ENDPOINTS),+ child_endpoint=endpoint,+ fanout=config.fanout,+ client_config=_client_config(api_key, _paginator(config)),+ path_format_values={},+ team_id=team_id,+ job_id=job_id,+ db_incremental_field_last_value=db_incremental_field_last_value,+ should_use_incremental_field=should_use_incremental_field,+ incremental_field=incremental_field,+ # The server-side time filter is already in `params`, converted to Unix seconds.+ incremental_config_factory=lambda _field: None,+ parent_endpoint_extra={+ "paginator": _paginator(parent_config),+ "data_selector": parent_config.items_key,+ },+ child_endpoint_extra={"paginator": _paginator(config), "data_selector": config.items_key},+ child_params_extra=params,+ page_size_param="page_size",+ ),+ )+ if endpoint in SECRET_BEARING_ENDPOINTS:+ resource.add_map(_redact_tool_secrets)+ return SourceResponse(+ name=endpoint,+ items=lambda: resource,+ primary_keys=config.primary_keys,+ sort_mode=config.sort_mode, # type: ignore[arg-type]+ **partition_kwargs,+ )+rest_config: RESTAPIConfig = {- "client": {- "base_url": ELEVENLABS_BASE_URL,- # Only the non-secret Accept header is set here; the key is injected via `auth` so it's- # redacted from logs and captured HTTP samples.- "headers": {"Accept": "application/json"},- "auth": {"type": "api_key", "api_key": api_key, "name": "xi-api-key", "location": "header"},- "paginator": ElevenLabsCursorPaginator(config.cursor_param, config.cursor_response_key),- # Redact the key and refuse redirects: requests preserves the custom `xi-api-key` header- # across a cross-origin 3xx, so following one could replay the key to another origin.- "session": make_tracked_session(redact_values=(api_key,), allow_redirects=False),- },+ "client": _client_config(api_key, _paginator(config)),"resources": [{"name": endpoint,@@ -238,15 +330,13 @@ def elevenlabs_source(resume_hook=save_checkpoint,initial_paginator_state=initial_paginator_state,)+ if endpoint in SECRET_BEARING_ENDPOINTS:+ resource.add_map(_redact_tool_secrets)return SourceResponse(name=endpoint,items=lambda: resource,primary_keys=config.primary_keys,sort_mode=config.sort_mode, # type: ignore[arg-type]- partition_count=1,- partition_size=1,- partition_mode="datetime",- partition_format="month",- partition_keys=[config.partition_key],+ **partition_kwargs,)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/settings.pyindex cba1c26e6b0c..92d4215074e9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/settings.py@@ -1,27 +1,34 @@from dataclasses import dataclass, fieldfrom typing import Optional+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ DependentEndpointConfig,+)from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType-@dataclass+@dataclass(frozen=True)class ElevenLabsEndpointConfig:name: str# Path appended to ELEVENLABS_BASE_URL, including the API version (v1/v2 differ per endpoint).path: str# Top-level array key in the JSON response body (differs per endpoint: history/conversations/...).- items_key: str- # Query param used to request the next page, and the response field that carries the next cursor.- # ElevenLabs uses three different cursor styles across endpoint families.- cursor_param: str- cursor_response_key: str+ # A JSONPath such as "$.*" selects the values of a body keyed by id; None takes a bare-array body.+ items_key: Optional[str]primary_keys: list[str]- page_size: int- partition_key: str+ # Query param used to request the next page, and the response field that carries the next cursor.+ # ElevenLabs uses three different cursor styles across endpoint families. Both None for+ # unpaginated endpoints that return the whole collection in one body.+ cursor_param: Optional[str] = None+ cursor_response_key: Optional[str] = None+ page_size: Optional[int] = None+ # None for tables without a stable creation timestamp; those small tables stay unpartitioned.+ partition_key: Optional[str] = None# Stable, monotonic incremental column and the server-side filter param that bounds it. Both None# for full-refresh endpoints (agents/voices expose no updated-since filter).incremental_field: Optional[str] = Noneincremental_param: Optional[str] = None+ incremental_field_type: IncrementalFieldType = IncrementalFieldType.Integer# "asc" checkpoints the watermark after every batch; "desc" defers it to successful job end. Must# match the order rows actually arrive in for the endpoint.sort_mode: str = "asc"@@ -31,17 +38,24 @@ class ElevenLabsEndpointConfig:should_sync_default: bool = True# Constant query params merged into every request (sort direction, summary mode, ...).extra_params: dict[str, str] = field(default_factory=dict)+ fanout: Optional[DependentEndpointConfig] = None+ @property+ def incremental_fields(self) -> list[IncrementalField]:+ if not self.incremental_field:+ return []+ return [+ {+ "label": self.incremental_field,+ "type": self.incremental_field_type,+ "field": self.incremental_field,+ "field_type": self.incremental_field_type,+ }+ ]-def _int_incremental_field(name: str) -> list[IncrementalField]:- return [- {- "label": name,- "type": IncrementalFieldType.Integer,- "field": name,- "field_type": IncrementalFieldType.Integer,- }- ]+ @property+ def default_incremental_field(self) -> Optional[str]:+ return self.incremental_fieldELEVENLABS_ENDPOINTS: dict[str, ElevenLabsEndpointConfig] = {@@ -124,11 +138,68 @@ ELEVENLABS_ENDPOINTS: dict[str, ElevenLabsEndpointConfig] = {sort_mode="desc",extra_params={"sort_by": "created_at"},),+ # Model catalog that resolves the `model_id` on history items. Returned as one bare array.+ "models": ElevenLabsEndpointConfig(+ name="models",+ path="/v1/models",+ items_key=None,+ primary_keys=["model_id"],+ ),+ # Workspace members (service accounts excluded) that resolve user ids on history and conversations.+ # Returned as one bare array; needs the `workspace_members_read` permission.+ "workspace_members": ElevenLabsEndpointConfig(+ name="workspace_members",+ path="/v1/workspace/members",+ items_key=None,+ primary_keys=["user_id"],+ ),+ # Returned as one object keyed by group id, so the selector takes its values.+ "workspace_groups": ElevenLabsEndpointConfig(+ name="workspace_groups",+ path="/v1/workspace/groups",+ items_key="$.*",+ primary_keys=["id"],+ ),+ # Conversational AI tool catalog. Mutable with no updated-since filter and no top-level creation+ # timestamp, so full refresh and unpartitioned. Ordered ascending by creation for stable pagination.+ "tools": ElevenLabsEndpointConfig(+ name="tools",+ path="/v1/convai/tools",+ items_key="tools",+ cursor_param="cursor",+ cursor_response_key="next_cursor",+ primary_keys=["id"],+ page_size=100,+ extra_params={"sort_by": "created_at", "sort_direction": "asc"},+ ),+ # Per-tool execution records, fanned out over `tools`. `start_time` (inclusive) bounds every page+ # server-side. The API documents no order, and rows from different tools interleave in time, so+ # "desc" defers the watermark to job end. `timestamp` is a float, which datetime partitioning+ # cannot bucket, so the table stays unpartitioned.+ "tool_executions": ElevenLabsEndpointConfig(+ name="tool_executions",+ path="/v1/convai/tools/{tool_id}/executions",+ items_key="executions",+ cursor_param="cursor",+ cursor_response_key="next_cursor",+ primary_keys=["tool_id", "id"],+ page_size=100,+ incremental_field="timestamp",+ incremental_param="start_time",+ incremental_field_type=IncrementalFieldType.Numeric,+ sort_mode="desc",+ fanout=DependentEndpointConfig(+ parent_name="tools",+ resolve_param="tool_id",+ resolve_field="id",+ include_from_parent=[],+ parent_params={"sort_by": "created_at", "sort_direction": "asc"},+ ),+ ),}ENDPOINTS = tuple(ELEVENLABS_ENDPOINTS.keys())INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {- name: (_int_incremental_field(config.incremental_field) if config.incremental_field else [])- for name, config in ELEVENLABS_ENDPOINTS.items()+ name: config.incremental_fields for name, config in ELEVENLABS_ENDPOINTS.items()}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/source.pyindex 225136b5a5f2..1f05061a3b58 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/source.py@@ -53,8 +53,10 @@ You can create an API key in your [ElevenLabs account settings](https://elevenlaGrant the following read permissions when creating the key:- **History** (text-to-speech generation history)-- **Conversational AI** (conversations, agents, and triage tickets)+- **Conversational AI** (conversations, agents, triage tickets, tools, and tool executions)- **Voices**+- **Models**+- **Workspace** (members and groups)""",iconPath="/static/services/elevenlabs.svg",docsUrl="https://posthog.com/docs/cdp/sources/elevenlabs",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/tests/test_elevenlabs.py b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/tests/test_elevenlabs.pyindex 4f29e778d730..b030980e0679 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/tests/test_elevenlabs.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/tests/test_elevenlabs.py@@ -104,7 +104,7 @@ class TestBuildParams:assert params["call_start_after_unix"] == 1700000000assert params["summary_mode"] == "include"- @parameterized.expand([("agents",), ("voices",), ("triage_tickets",)])+ @parameterized.expand([("agents",), ("voices",), ("triage_tickets",), ("tools",)])def test_full_refresh_endpoints_never_send_a_time_filter(self, endpoint: str) -> None:# Full-refresh endpoints have no server-side updated-since filter; sending one would 4xx.params = _build_params(ELEVENLABS_ENDPOINTS[endpoint], True, 1700000000, "created_at_unix")@@ -158,6 +158,143 @@ class TestPagination:assert session.send.call_count == 1+class TestFanOut:+ @parameterized.expand(+ [+ ("full_refresh", False, None),+ ("incremental", True, 1700000000.5),+ ]+ )+ @mock.patch(SESSION_PATCH)+ def test_tool_executions_walk_every_tool_and_page(+ self, _name: str, use_incremental: bool, last_value: Any, MockSession+ ) -> None:+ session = MockSession.return_value+ params = _wire(+ session,+ [+ _response({"tools": [{"id": "t1"}, {"id": "t2"}], "has_more": False, "next_cursor": None}),+ _response({"executions": [{"id": "e1", "tool_id": "t1"}], "has_more": True, "next_cursor": "c1"}),+ _response({"executions": [{"id": "e2", "tool_id": "t1"}], "has_more": False, "next_cursor": None}),+ _response({"executions": [{"id": "e3", "tool_id": "t2"}], "has_more": False, "next_cursor": None}),+ ],+ )+ rows = _rows(+ _source(+ "tool_executions",+ _make_manager(),+ should_use_incremental_field=use_incremental,+ db_incremental_field_last_value=last_value,+ incremental_field="timestamp" if use_incremental else None,+ )+ )++ assert [row["id"] for row in rows] == ["e1", "e2", "e3"]+ assert params[0]["sort_by"] == "created_at"+ assert "start_time" not in params[0]+ assert params[2]["cursor"] == "c1"+ # The time filter binds every child page, so incremental runs never re-walk full history.+ for child_params in params[1:]:+ if use_incremental:+ assert child_params["start_time"] == 1700000000+ else:+ assert "start_time" not in child_params+++class TestSecretRedaction:+ @parameterized.expand(+ [+ (+ "tool_config_headers",+ "tools",+ [+ {+ "tools": [+ {+ "id": "t1",+ "tool_config": {+ "api_schema": {+ "request_headers": {+ "Authorization": "Bearer sk_fake",+ "X-Ref": {"secret_id": "s1"},+ }+ }+ },+ }+ ],+ "has_more": False,+ }+ ],+ lambda row: row["tool_config"]["api_schema"]["request_headers"],+ ),+ (+ "execution_sent_headers",+ "tool_executions",+ [+ {"tools": [{"id": "t1"}], "has_more": False},+ {+ "executions": [+ {+ "id": "e1",+ "tool_id": "t1",+ "tool_call_details": {+ "headers": {"Authorization": "Bearer sk_fake", "X-Ref": {"secret_id": "s1"}}+ },+ }+ ],+ "has_more": False,+ },+ ],+ lambda row: row["tool_call_details"]["headers"],+ ),+ ]+ )+ @mock.patch(SESSION_PATCH)+ def test_literal_header_values_never_reach_the_warehouse(+ self, _name: str, endpoint: str, bodies: list[dict[str, Any]], headers_of: Any, MockSession+ ) -> None:+ _wire(MockSession.return_value, [_response(body) for body in bodies])++ rows = _rows(_source(endpoint, _make_manager()))++ # A secret reference is safe to keep and tells the reader which secret the tool uses.+ assert headers_of(rows[0]) == {"Authorization": "[REDACTED]", "X-Ref": {"secret_id": "s1"}}+++class TestUnpaginatedEndpoints:+ @parameterized.expand(+ [+ ("models_bare_array", "models", [{"model_id": "m1"}, {"model_id": "m2"}], ["m1", "m2"], "model_id"),+ (+ "groups_keyed_by_id",+ "workspace_groups",+ {"g1": {"id": "g1", "name": "a"}, "g2": {"id": "g2", "name": "b"}},+ ["g1", "g2"],+ "id",+ ),+ # jsonpath unwraps a single match, so a one-group body must still come back as one row.+ ("single_group", "workspace_groups", {"g1": {"id": "g1", "name": "a"}}, ["g1"], "id"),+ ("no_groups", "workspace_groups", {}, [], "id"),+ ]+ )+ @mock.patch(SESSION_PATCH)+ def test_whole_collection_becomes_rows(+ self, _name: str, endpoint: str, body: Any, expected_ids: list[str], id_key: str, MockSession+ ) -> None:+ session = MockSession.return_value+ response = Response()+ response.status_code = 200+ response._content = json.dumps(body).encode()+ response.url = "https://api.elevenlabs.io/v1/workspace/groups"+ params = _wire(session, [response])++ rows = _rows(_source(endpoint, _make_manager()))++ assert [row[id_key] for row in rows] == expected_ids+ assert session.send.call_count == 1+ assert "page_size" not in params[0]++class TestValidateCredentials:@parameterized.expand([@@ -178,6 +315,18 @@ class TestValidateCredentials:ok, _msg = validate_credentials("k", schema_name)assert ok is expected_ok+ @parameterized.expand(+ [+ ("fan_out_child_probes_parent", "tool_executions", "https://api.elevenlabs.io/v1/convai/tools?page_size=1"),+ ("unpaginated_sends_no_page_size", "workspace_members", "https://api.elevenlabs.io/v1/workspace/members"),+ ]+ )+ @mock.patch(SESSION_PATCH)+ def test_schema_probe_url(self, _name: str, schema_name: str, expected_url: str, mts) -> None:+ mts.return_value.get.return_value = mock.MagicMock(status_code=200)+ assert validate_credentials("k", schema_name) == (True, None)+ assert mts.return_value.get.call_args.args[0] == expected_url+@mock.patch(SESSION_PATCH)def test_network_error_is_not_valid(self, mts) -> None:mts.return_value.get.side_effect = requests.ConnectionError("boom")@@ -212,15 +361,25 @@ class TestSourceResponse:("agents", ["agent_id"], "asc", "created_at_unix_secs"),("voices", ["voice_id"], "asc", "created_at_unix"),("triage_tickets", ["agentqa_ticket_id"], "desc", "created_at_unix_secs"),+ ("models", ["model_id"], "asc", None),+ ("workspace_members", ["user_id"], "asc", None),+ ("workspace_groups", ["id"], "asc", None),+ ("tools", ["id"], "asc", None),+ # Executions from different tools interleave in time, so the watermark must wait for job end.+ ("tool_executions", ["tool_id", "id"], "desc", None),])@mock.patch(SESSION_PATCH)def test_response_shape_per_endpoint(- self, endpoint: str, primary_keys: list[str], sort_mode: str, partition_key: str, _mts+ self, endpoint: str, primary_keys: list[str], sort_mode: str, partition_key: str | None, _mts) -> None:# sort_mode="asc" on a newest-first endpoint corrupts the watermark; the pk must be table-unique.response = _source(endpoint, _make_manager())assert response.primary_keys == primary_keysassert response.sort_mode == sort_mode- assert response.partition_keys == [partition_key]- assert response.partition_mode == "datetime"+ if partition_key is None:+ # A float or missing timestamp would bucket every row into one bogus 1970 partition.+ assert response.partition_mode is None+ else:+ assert response.partition_keys == [partition_key]+ assert response.partition_mode == "datetime"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/tests/test_elevenlabs_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/tests/test_elevenlabs_source.pyindex 1de1211fe788..63d3e8cb1fc3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/tests/test_elevenlabs_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/elevenlabs/tests/test_elevenlabs_source.py@@ -15,6 +15,12 @@ class TestElevenLabsSchemas:("agents", False, False),("voices", False, False),("triage_tickets", False, False),+ ("models", False, False),+ ("workspace_members", False, False),+ ("workspace_groups", False, False),+ ("tools", False, False),+ # Executions take a server-side `start_time` filter, so they merge incrementally.+ ("tool_executions", True, False),])def test_schema_sync_capabilities(self, endpoint: str, incremental: bool, append: bool) -> None: