: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(warehouse_sources): support quo API version 2026-03-30 (#113251)
Tom Owersb312aec30718
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.mdindex d9817f734e87..887af8dc0c2a 100644--- a/.agents/skills/warehouse-source-new-version/SKILL.md+++ b/.agents/skills/warehouse-source-new-version/SKILL.md@@ -102,7 +102,7 @@ The opposite gap also occurs: a reference rendered from one version-blind OpenAP- A vendor that falls forward on a retired pin — serving the oldest accessible version instead of rejecting the request — has no rejection signature to add. Its sunset still needs the repin migration: the pin silently stops being honored, with no failed sync to surface it.- A version bump can change the auth scheme, not just the wire format. Then the source config needs both credential shapes as optional fields, auth construction dispatches on the resolved version, and `validate_credentials` enforces the pair that version needs — form-level `required` can't express "depends on the pin".- A new version can page a horizon the old one returned whole (a fixed record cap plus `next`/`prev` links). For a snapshot-polling source, keep one request per sync rather than following the links — vendors bill each page — and state the resulting horizon in each table's description, since it can be shorter than the old version's.-- A version that changes the pagination _mechanism_ (e.g. offset→cursor) also changes the resumable checkpoint's persisted shape. Add a new defaulted field to the resume-config dataclass rather than repurposing the existing one — so state persisted under the old version still decodes — and make the seed and save-checkpoint logic dispatch on the resolved version. Reusing one field across incompatible mechanisms corrupts in-flight resumes of the other version.+- A version that changes the pagination _mechanism_ (e.g. offset→cursor, or one opaque cursor param for another, since a token one generation issued means nothing to the other) also changes the resumable checkpoint's persisted shape. Add a new defaulted field to the resume-config dataclass rather than repurposing the existing one — so state persisted under the old version still decodes — and make the seed and save-checkpoint logic dispatch on the resolved version. Reusing one field across incompatible mechanisms corrupts in-flight resumes of the other version. When a table stays on its old wire under the new pin, key the check on the wire that issued the cursor, not on the pin.- When the vendor renames a collection between versions, keep the schema/table name set identical across versions and put the rename in a per-version path on the endpoint config — otherwise discovery diffs orphan the table on repin.- When the new version has no equivalent for an old endpoint (a dropped collection, not a rename), keep that table only on the versions that serve it and let the table set differ by version — never map it to a guessed path just to keep the sets equal, since docs are the sole source of truth and an unverified path makes a new source surface a table that 404s at sync time.- A source with no dispatch may currently read its version from a constant on a shared model (e.g. the OAuth `Integration` model) that also drives version-independent flows like OAuth token minting. Repoint only the sync request path onto the resolved pin; leave that constant, since bumping it changes those other flows' version with a blast radius beyond this source.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/canonical_descriptions.pyindex 0382d550f1bc..320a0d2e1284 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/canonical_descriptions.py@@ -12,6 +12,7 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"groupId": "The unique identifier of the group the Quo number belongs to.","name": "The display name of the phone number.","number": "The phone number in E.164 format, including the country code.",+ "phoneNumber": "The phone number in E.164 format, including the country code.","formattedNumber": "The phone number in a human-readable format.","users": "The users assigned to the phone number.","restrictions": "Messaging and calling restrictions that apply to the phone number.",@@ -41,6 +42,10 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"source": "The external system the contact came from.","sourceUrl": "A link to the contact in the external system it came from.","defaultFields": "The contact's standard fields: name, company, role, emails and phone numbers.",+ "firstName": "The contact's first name.",+ "lastName": "The contact's last name.",+ "company": "The contact's company.",+ "role": "The contact's role.","customFields": "The contact's custom fields, as defined in the workspace's contact custom fields.","createdByUserId": "The unique identifier of the user who created the contact.","createdAt": "Timestamp of contact creation, in ISO 8601 format.",@@ -81,6 +86,7 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"id": "The unique identifier of the call.","phoneNumberId": "The unique identifier of the Quo number associated with the call.","userId": "The unique identifier of the Quo user associated with the call.",+ "actorId": "The unique identifier of the Quo user or system actor, such as an AI agent, associated with the call.","participants": "The phone numbers involved in the call, including the Quo number, in E.164 format.","direction": "The direction of the call relative to the Quo number: incoming or outgoing.","status": "The current status of the call.",@@ -91,6 +97,7 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"completedAt": "Timestamp of when the call ended, in ISO 8601 format.","forwardedFrom": "The number the call was forwarded from.","forwardedTo": "The number the call was forwarded to.",+ "summary": "The AI-generated call summary, with its generation status, title, summary text and next steps.","createdAt": "Timestamp of when the call record was created, in ISO 8601 format.","updatedAt": "Timestamp of when the call record was last updated, in ISO 8601 format.",},diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/quo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/quo.pyindex 1c6a39ce2aac..7176398a3544 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/quo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/quo.py@@ -19,8 +19,12 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.schfrom 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 SourceResponsefrom products.warehouse_sources.backend.temporal.data_imports.sources.quo.settings import (+ DATED_ENDPOINTS_BY_VERSION,+ QUO_API_VERSION_HEADER,+ QUO_API_VERSION_V1,QUO_BASE_URL,QUO_ENDPOINTS,+ QuoDatedEndpointConfig,QuoEndpointConfig,)@@ -28,6 +32,8 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.quo.settin@frozenclass QuoResumeConfig:page_token: str+ # The dated version the cursor was issued under. None is the v1 wire, which pages with incompatible cursors.+ api_version: str | None = Nonedef _to_iso(value: Any) -> Optional[str]:@@ -41,12 +47,29 @@ def _auth_headers(api_key: str) -> dict[str, str]:return {"Accept": "application/json", "Authorization": api_key}-def validate_credentials(api_key: str) -> bool:- """Confirm the API key is valid. /v1/phone-numbers is a cheap authenticated probe with no required params."""+def _dated_endpoints(api_version: str) -> Optional[dict[str, QuoDatedEndpointConfig]]:+ """Return the dated endpoint map for a version, or None for v1. Unknown versions raise rather than send no header."""+ if api_version == QUO_API_VERSION_V1:+ return None+ try:+ return DATED_ENDPOINTS_BY_VERSION[api_version]+ except KeyError:+ raise ValueError(f"Unsupported Quo API version: {api_version}")+++def validate_credentials(api_key: str, api_version: str) -> bool:+ """Confirm the API key is valid. Listing phone numbers is a cheap authenticated probe with no required params."""+ dated_endpoints = _dated_endpoints(api_version)+ headers = _auth_headers(api_key)+ if dated_endpoints is None:+ url = f"{QUO_BASE_URL}/v1/phone-numbers"+ else:+ url = f"{QUO_BASE_URL}{dated_endpoints['phone_numbers'].path}"+ headers[QUO_API_VERSION_HEADER] = api_versionok, _status = validate_via_probe(lambda: make_tracked_session(redact_values=(api_key,)),- f"{QUO_BASE_URL}/v1/phone-numbers",- headers=_auth_headers(api_key),+ url,+ headers=headers,)return ok@@ -64,6 +87,19 @@ def _build_params(return params+def _build_dated_params(+ config: QuoDatedEndpointConfig, cursor_field: Optional[str], watermark_iso: Optional[str]+) -> dict[str, Any]:+ params: dict[str, Any] = {"limit": config.page_size}+ if config.include is not None:+ params["include"] = config.include+ if watermark_iso is not None and cursor_field is not None:+ server_filter = config.incremental_params.get(cursor_field)+ if server_filter is not None:+ params[server_filter] = watermark_iso+ return params++def _paginate(session: Session, path: str, params: dict[str, Any]) -> Iterator[list[dict[str, Any]]]:"""Yield pages of `data` rows, following the `nextPageToken` cursor until it runs out."""page_token: Optional[str] = None@@ -116,29 +152,38 @@ def _fan_out_rows(api_key: str, config: QuoEndpointConfig, params: dict[str, Anydef _rest_source(api_key: str,- config: QuoEndpointConfig,+ name: str,+ path: str,+ dated_version: Optional[str],team_id: int,job_id: str,resumable_source_manager: ResumableSourceManager[QuoResumeConfig],params: dict[str, Any],db_incremental_field_last_value: Optional[Any],):+ headers = {"Accept": "application/json"}+ if dated_version is not None:+ headers[QUO_API_VERSION_HEADER] = dated_version+ paginator = JSONResponseCursorPaginator(cursor_path="nextCursor", cursor_param="after")+ else:+ # Also used for the endpoints documented as unpaginated: with no nextPageToken in the+ # body it stops after one page, and it follows the cursor if Quo ever adds one.+ paginator = JSONResponseCursorPaginator(cursor_path="nextPageToken", cursor_param="pageToken")+rest_config: RESTAPIConfig = {"client": {"base_url": QUO_BASE_URL,- "headers": {"Accept": "application/json"},+ "headers": headers,# The framework auth redacts the key from logs. Quo's Authorization header carries# the raw key, which is exactly what api_key auth with the default name sends."auth": {"type": "api_key", "api_key": api_key, "name": "Authorization", "location": "header"},- # Also used for the endpoints documented as unpaginated: with no nextPageToken in the- # body it stops after one page, and it follows the cursor if Quo ever adds one.- "paginator": JSONResponseCursorPaginator(cursor_path="nextPageToken", cursor_param="pageToken"),+ "paginator": paginator,},"resources": [{- "name": config.name,+ "name": name,"endpoint": {- "path": config.path,+ "path": path,"data_selector": "data","params": params,},@@ -149,14 +194,16 @@ def _rest_source(initial_paginator_state: Optional[dict[str, Any]] = Noneif resumable_source_manager.can_resume():resume = resumable_source_manager.load_state()- if resume is not None:+ if resume is not None and resume.api_version == dated_version:initial_paginator_state = {"cursor": resume.page_token}def save_checkpoint(state: Optional[dict[str, Any]]) -> None:# Persist only while a next page remains; the state is saved after the page it covers# is yielded, so a crash re-yields that page and merge dedupes it.if state and state.get("cursor"):- resumable_source_manager.save_state(QuoResumeConfig(page_token=str(state["cursor"])))+ resumable_source_manager.save_state(+ QuoResumeConfig(page_token=str(state["cursor"]), api_version=dated_version)+ )return rest_api_resource(rest_config,@@ -191,14 +238,32 @@ def quo_source(team_id: int,job_id: str,resumable_source_manager: ResumableSourceManager[QuoResumeConfig],+ api_version: str,should_use_incremental_field: bool = False,db_incremental_field_last_value: Optional[Any] = None,incremental_field: str | None = None,) -> SourceResponse:config = schema_for_resource(QUO_ENDPOINTS, endpoint)+ dated_endpoints = _dated_endpoints(api_version)+ dated_config = dated_endpoints.get(endpoint) if dated_endpoints is not None else Nonelast_value = db_incremental_field_last_value if should_use_incremental_field else Nonecursor_field = incremental_field or (config.incremental_fields[0]["field"] if config.incremental_fields else None)++ if dated_config is not None:+ resource = _rest_source(+ api_key,+ config.name,+ dated_config.path,+ api_version,+ team_id,+ job_id,+ resumable_source_manager,+ _build_dated_params(dated_config, cursor_field, _to_iso(last_value)),+ last_value,+ )+ return _source_response(endpoint, config, lambda: resource)+params = _build_params(config, cursor_field, _to_iso(last_value))if config.fan_out_over_conversations:@@ -206,7 +271,9 @@ def quo_source(resource = _rest_source(api_key,- config,+ config.name,+ config.path,+ None,team_id,job_id,resumable_source_manager,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/settings.pyindex 08ddea6c915f..a211f8b77c3f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/settings.py@@ -7,10 +7,18 @@ from products.warehouse_sources.backend.types import IncrementalFieldQUO_BASE_URL = "https://api.quo.com"+# v1 carries its version in the URL path. Dated versions drop the path prefix and require the+# version in a header on every request; Quo has no default version, so a missing header is a 400.+QUO_API_VERSION_V1 = "v1"+QUO_API_VERSION_2026_03_30 = "2026-03-30"+QUO_API_VERSION_HEADER = "Quo-Api-Version"+# Quo caps `maxResults` at 100 on calls, messages and conversations, and at 50 on contacts.# The users endpoint declares no maximum in the OpenAPI spec, so it stays on the lower cap.MAX_PAGE_SIZE = 100SMALL_PAGE_SIZE = 50+# Dated versions cap `limit` at 50 on every list endpoint.+DATED_PAGE_SIZE = 50@frozen@@ -86,6 +94,40 @@ QUO_ENDPOINTS: dict[str, QuoEndpointConfig] = {),}++@frozen+class QuoDatedEndpointConfig:+ path: str+ page_size: int = DATED_PAGE_SIZE+ # Incremental field name -> the bracketed range filter that bounds it.+ incremental_params: dict[str, str] = field(default_factory=dict)+ # Optional payload sections that the dated list omits unless asked for.+ include: str | None = None+++# Tables missing here have no dated equivalent and stay on their v1 path under every version.+# 2026-03-30 lists calls and messages workspace-wide, so neither fans out over conversations.+QUO_2026_03_30_ENDPOINTS: dict[str, QuoDatedEndpointConfig] = {+ "phone_numbers": QuoDatedEndpointConfig(path="/phone-numbers", include="restrictions"),+ "users": QuoDatedEndpointConfig(path="/users"),+ "contacts": QuoDatedEndpointConfig(path="/contacts"),+ "conversations": QuoDatedEndpointConfig(+ path="/conversations",+ incremental_params={"createdAt": "createdAt[gte]", "updatedAt": "updatedAt[gte]"},+ ),+ "calls": QuoDatedEndpointConfig(+ path="/calls",+ incremental_params={"createdAt": "createdAt[gte]"},+ include="summary",+ ),+ # /messages accepts only the exclusive `gt`/`lt` pair on createdAt.+ "messages": QuoDatedEndpointConfig(path="/messages", incremental_params={"createdAt": "createdAt[gt]"}),+}++DATED_ENDPOINTS_BY_VERSION: dict[str, dict[str, QuoDatedEndpointConfig]] = {+ QUO_API_VERSION_2026_03_30: QUO_2026_03_30_ENDPOINTS,+}+ENDPOINTS = tuple(QUO_ENDPOINTS.keys())INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/source.pyindex e488171c2ba6..56a1dc5eb7c0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/source.py@@ -24,7 +24,14 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.quo.quo imquo_source,validate_credentials as validate_quo_credentials,)-from products.warehouse_sources.backend.temporal.data_imports.sources.quo.settings import ENDPOINTS, INCREMENTAL_FIELDS+from products.warehouse_sources.backend.temporal.data_imports.sources.quo.settings import (+ DATED_ENDPOINTS_BY_VERSION,+ ENDPOINTS,+ INCREMENTAL_FIELDS,+ QUO_API_VERSION_2026_03_30,+ QUO_API_VERSION_V1,+ QUO_BASE_URL,+)from products.warehouse_sources.backend.types import ExternalDataSourceType@@ -32,8 +39,8 @@ from products.warehouse_sources.backend.types import ExternalDataSourceTypeclass QuoSource(ResumableSource[QuoSourceConfig, QuoResumeConfig]):lists_tables_without_credentials = True # static endpoint catalog, safe for public docs- supported_versions = ("v1",)- default_version = "v1"+ supported_versions = (QUO_API_VERSION_V1, QUO_API_VERSION_2026_03_30)+ default_version = QUO_API_VERSION_2026_03_30api_docs_url = "https://www.quo.com/docs/mdx/api-reference/changelog"@property@@ -41,10 +48,18 @@ class QuoSource(ResumableSource[QuoSourceConfig, QuoResumeConfig]):return ExternalDataSourceType.QUOdef get_non_retryable_errors(self) -> dict[str, str | None]:- return {+ errors: dict[str, str | None] = {"401 Client Error: Unauthorized for url: https://api.quo.com": "Quo authentication failed. Check that your API key is correct and still active, then reconnect.","403 Client Error: Forbidden for url: https://api.quo.com": "Quo denied access. Check that the API key was created by a workspace owner or admin.",}+ # Dated versions answer a missing or unsupported Quo-Api-Version header with a 400, which no retry fixes.+ # Keyed per dated path so v1 URLs, which all start with /v1/, never match.+ for dated_endpoints in DATED_ENDPOINTS_BY_VERSION.values():+ for config in dated_endpoints.values():+ errors[f"400 Client Error: Bad Request for url: {QUO_BASE_URL}{config.path}"] = (+ "Quo rejected the request. Check that Quo still supports the API version this source uses."+ )+ return errorsdef get_canonical_descriptions(self) -> CanonicalDescriptions:from products.warehouse_sources.backend.temporal.data_imports.sources.quo.canonical_descriptions import (@@ -71,7 +86,7 @@ class QuoSource(ResumableSource[QuoSourceConfig, QuoResumeConfig]):schema_name: Optional[str] = None,api_version: str | None = None,) -> tuple[bool, str | None]:- if validate_quo_credentials(config.api_key):+ if validate_quo_credentials(config.api_key, self.resolve_api_version(api_version)):return True, Nonereturn False, "Invalid Quo API key"@@ -91,6 +106,7 @@ class QuoSource(ResumableSource[QuoSourceConfig, QuoResumeConfig]):team_id=inputs.team_id,job_id=inputs.job_id,resumable_source_manager=resumable_source_manager,+ api_version=self.resolve_api_version(inputs.api_version),should_use_incremental_field=inputs.should_use_incremental_field,db_incremental_field_last_value=inputs.db_incremental_field_last_value,incremental_field=inputs.incremental_field,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/tests/test_quo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/tests/test_quo.pyindex 035f79d9b4c1..2c5c6c15c000 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/tests/test_quo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/tests/test_quo.py@@ -15,7 +15,12 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.quo.quo imquo_source,validate_credentials,)-from products.warehouse_sources.backend.temporal.data_imports.sources.quo.settings import ENDPOINTS, QUO_ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.quo.settings import (+ ENDPOINTS,+ QUO_API_VERSION_2026_03_30,+ QUO_API_VERSION_V1,+ QUO_ENDPOINTS,+)# RESTClient builds its session via make_tracked_session in the rest_client module.CLIENT_SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client.make_tracked_session"@@ -72,8 +77,10 @@ def _wire(session: mock.MagicMock, responses: list[Response]) -> list[dict[str,return snapshots-def _source(endpoint: str, manager: mock.MagicMock, **kwargs: Any):- return quo_source("key", endpoint, team_id=1, job_id="j", resumable_source_manager=manager, **kwargs)+def _source(endpoint: str, manager: mock.MagicMock, api_version: str = QUO_API_VERSION_V1, **kwargs: Any):+ return quo_source(+ "key", endpoint, team_id=1, job_id="j", resumable_source_manager=manager, api_version=api_version, **kwargs+ )def _rows(source_response) -> list[dict[str, Any]]:@@ -110,23 +117,33 @@ class TestValidateCredentials:def test_validate_credentials_status_mapping(self, mock_session, status_code, expected):mock_session.return_value.get.return_value = mock.MagicMock(status_code=status_code)- assert validate_credentials("key") is expected+ assert validate_credentials("key", QUO_API_VERSION_2026_03_30) is expected@mock.patch(QUO_SESSION_PATCH)def test_validate_credentials_swallows_exceptions(self, mock_session):mock_session.return_value.get.side_effect = Exception("boom")- assert validate_credentials("key") is False+ assert validate_credentials("key", QUO_API_VERSION_2026_03_30) is False+ @pytest.mark.parametrize(+ "api_version, expected_url, expected_version_header",+ [+ (QUO_API_VERSION_V1, "https://api.quo.com/v1/phone-numbers", None),+ (QUO_API_VERSION_2026_03_30, "https://api.quo.com/phone-numbers", "2026-03-30"),+ ],+ )@mock.patch(QUO_SESSION_PATCH)- def test_validate_credentials_probes_phone_numbers_with_raw_key(self, mock_session):+ def test_validate_credentials_probes_phone_numbers_with_raw_key(+ self, mock_session, api_version, expected_url, expected_version_header+ ):mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)- validate_credentials("key")+ validate_credentials("key", api_version)call = mock_session.return_value.get.call_args- assert call.args[0] == "https://api.quo.com/v1/phone-numbers"+ assert call.args[0] == expected_url# Quo takes the raw key in the Authorization header, with no Bearer prefix.assert call.kwargs["headers"]["Authorization"] == "key"+ assert call.kwargs["headers"].get("Quo-Api-Version") == expected_version_headerclass TestTopLevelPagination:@@ -173,6 +190,15 @@ class TestTopLevelPagination:assert [row["id"] for row in rows] == ["US9"]assert requests_seen[0]["params"]["pageToken"] == "tok5"+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_ignores_state_saved_under_a_dated_version(self, MockSession):+ session = MockSession.return_value+ requests_seen = _wire(session, [_response([{"id": "US9"}])])++ _rows(_source("users", _make_manager(QuoResumeConfig(page_token="cur5", api_version="2026-03-30"))))++ assert "pageToken" not in requests_seen[0]["params"]+@mock.patch(CLIENT_SESSION_PATCH)def test_unpaginated_endpoint_issues_one_request_without_page_size(self, MockSession):session = MockSession.return_value@@ -338,6 +364,112 @@ class TestFanOut:assert requests_seen[1][1]["createdAfter"] == WATERMARK_ISO+def _dated_response(items: list[dict[str, Any]], next_cursor: str | None = None) -> Response:+ resp = Response()+ resp.status_code = 200+ resp._content = json.dumps({"data": items, "nextCursor": next_cursor}).encode()+ return resp+++class TestDatedVersion:+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_paginates_via_after_cursor_with_version_header(self, MockSession):+ session = MockSession.return_value+ requests_seen = _wire(+ session,+ [+ _dated_response([{"id": "US1"}, {"id": "US2"}], next_cursor="cur"),+ _dated_response([{"id": "US3"}]),+ ],+ )++ manager = _make_manager()+ rows = _rows(_source("users", manager, api_version=QUO_API_VERSION_2026_03_30))++ assert [row["id"] for row in rows] == ["US1", "US2", "US3"]+ assert requests_seen[0]["url"] == "https://api.quo.com/users"+ assert requests_seen[0]["params"] == {"limit": 50}+ assert requests_seen[1]["params"] == {"limit": 50, "after": "cur"}+ assert session.headers["Quo-Api-Version"] == "2026-03-30"+ manager.save_state.assert_called_once_with(QuoResumeConfig(page_token="cur", api_version="2026-03-30"))++ @pytest.mark.parametrize(+ "resume_state, expected_after",+ [+ (QuoResumeConfig(page_token="cur5", api_version="2026-03-30"), "cur5"),+ # A v1 pageToken means nothing to the dated `after` param.+ (QuoResumeConfig(page_token="tok5"), None),+ ],+ )+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_resumes_only_from_state_saved_on_the_same_wire(self, MockSession, resume_state, expected_after):+ session = MockSession.return_value+ requests_seen = _wire(session, [_dated_response([{"id": "US9"}])])++ _rows(_source("users", _make_manager(resume_state), api_version=QUO_API_VERSION_2026_03_30))++ assert requests_seen[0]["params"].get("after") == expected_after++ @pytest.mark.parametrize(+ "endpoint, incremental_field, expected_params",+ [+ ("conversations", "createdAt", {"limit": 50, "createdAt[gte]": WATERMARK_ISO}),+ ("conversations", "updatedAt", {"limit": 50, "updatedAt[gte]": WATERMARK_ISO}),+ ("calls", "createdAt", {"limit": 50, "include": "summary", "createdAt[gte]": WATERMARK_ISO}),+ ("messages", "createdAt", {"limit": 50, "createdAt[gt]": WATERMARK_ISO}),+ ],+ )+ @mock.patch(QUO_SESSION_PATCH)+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_incremental_run_uses_range_filters_without_fan_out(+ self, MockSession, mock_fan_out_session, endpoint, incremental_field, expected_params+ ):+ session = MockSession.return_value+ requests_seen = _wire(session, [_dated_response([{"id": "X1"}])])++ rows = _rows(+ _source(+ endpoint,+ _make_manager(),+ api_version=QUO_API_VERSION_2026_03_30,+ should_use_incremental_field=True,+ db_incremental_field_last_value=WATERMARK,+ incremental_field=incremental_field,+ )+ )++ assert [row["id"] for row in rows] == ["X1"]+ assert len(requests_seen) == 1+ assert requests_seen[0]["url"] == f"https://api.quo.com/{endpoint}"+ assert requests_seen[0]["params"] == expected_params+ mock_fan_out_session.assert_not_called()++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_phone_numbers_request_restrictions(self, MockSession):+ session = MockSession.return_value+ requests_seen = _wire(session, [_dated_response([{"id": "PN1"}])])++ _rows(_source("phone_numbers", _make_manager(), api_version=QUO_API_VERSION_2026_03_30))++ assert requests_seen[0]["url"] == "https://api.quo.com/phone-numbers"+ assert requests_seen[0]["params"] == {"limit": 50, "include": "restrictions"}++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_contact_custom_fields_stay_on_v1_wire(self, MockSession):+ session = MockSession.return_value+ requests_seen = _wire(session, [_response([{"key": "k1"}])])++ rows = _rows(_source("contact_custom_fields", _make_manager(), api_version=QUO_API_VERSION_2026_03_30))++ assert [row["key"] for row in rows] == ["k1"]+ assert requests_seen[0]["url"] == "https://api.quo.com/v1/contact-custom-fields"+ assert "Quo-Api-Version" not in session.headers++ def test_unknown_version_raises(self):+ with pytest.raises(ValueError, match="Unsupported Quo API version"):+ _source("users", _make_manager(), api_version="2099-01-01")++class TestQuoSourceResponse:def test_unknown_endpoint_raises_unknown_resource(self):with pytest.raises(UnknownResourceError):diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/tests/test_quo_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/tests/test_quo_source.pyindex 052dc5ad0579..e967adf02361 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/quo/tests/test_quo_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/quo/tests/test_quo_source.py@@ -16,6 +16,7 @@ class TestQuoSource:["401 Client Error: Unauthorized for url: https://api.quo.com/v1/conversations?maxResults=100","403 Client Error: Forbidden for url: https://api.quo.com/v1/calls?phoneNumberId=PN1",+ "400 Client Error: Bad Request for url: https://api.quo.com/calls?limit=50",],)def test_non_retryable_errors_match_quo_client_errors(self, observed_error):@@ -28,6 +29,7 @@ class TestQuoSource:"401 Client Error: Unauthorized for url: https://api.stripe.com/v1/customers","500 Server Error for url: https://api.quo.com/v1/calls","429 Client Error: Too Many Requests for url: https://api.quo.com/v1/messages",+ "400 Client Error: Bad Request for url: https://api.quo.com/v1/calls?phoneNumberId=PN1",],)def test_non_retryable_errors_do_not_match_retryable_or_unrelated(self, other_error):@@ -35,18 +37,37 @@ class TestQuoSource:assert not any(key in other_error for key in non_retryable_errors)@pytest.mark.parametrize(- "mock_return, expected_valid, expected_message",+ "mock_return, api_version, expected_valid, expected_message, expected_version",[- (True, True, None),- (False, False, "Invalid Quo API key"),+ (True, None, True, None, "2026-03-30"),+ (True, "v1", True, None, "v1"),+ (False, None, False, "Invalid Quo API key", "2026-03-30"),],)@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.quo.source.validate_quo_credentials")- def test_validate_credentials(self, mock_validate, mock_return, expected_valid, expected_message):+ def test_validate_credentials(+ self, mock_validate, mock_return, api_version, expected_valid, expected_message, expected_version+ ):mock_validate.return_value = mock_return- is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)+ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id, api_version=api_version)assert is_valid is expected_validassert error_message == expected_message- mock_validate.assert_called_once_with(self.config.api_key)+ mock_validate.assert_called_once_with(self.config.api_key, expected_version)++ @pytest.mark.parametrize(+ "pinned_version, expected_version",+ [+ (None, "2026-03-30"),+ ("v1", "v1"),+ ("2026-03-30", "2026-03-30"),+ ],+ )+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.quo.source.quo_source")+ def test_source_for_pipeline_passes_resolved_version(self, mock_quo_source, pinned_version, expected_version):+ inputs = mock.MagicMock(api_version=pinned_version)++ self.source.source_for_pipeline(self.config, mock.MagicMock(), inputs)++ assert mock_quo_source.call_args.kwargs["api_version"] == expected_version