: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
fix(data-warehouse): drop retired cohere connectors and fine-tuning tables (#103659)
Tom Owersf6853bc2f6b2
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/canonical_descriptions.pyindex 920ea4745129..02ab98ba64d6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/canonical_descriptions.py@@ -25,25 +25,6 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"schema": "The inferred schema of the dataset.",},},- "connectors": {- "description": (- "A connector that lets Cohere's chat models retrieve documents from an external data source. "- "Cohere deprecated connectors on September 15, 2025 and closed them to new accounts, so only "- "accounts that already used connectors can sync this table."- ),- "docs_url": "https://docs.cohere.com/reference/list-connectors",- "columns": {- "id": "Unique identifier for the connector.",- "name": "Human-readable name of the connector.",- "description": "A description of the connector.",- "url": "The URL Cohere queries to retrieve documents.",- "created_at": "Time at which the connector was created.",- "updated_at": "Time at which the connector was last updated.",- "organization_id": "The organization that owns the connector.",- "active": "Whether the connector is active.",- "auth_status": "The authentication status of the connector (e.g. valid, expired).",- },- },"models": {"description": "A model available to your account in the Cohere model catalog.","docs_url": "https://docs.cohere.com/reference/list-models",@@ -56,22 +37,6 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"default_endpoints": "The endpoints for which this model is the default.",},},- "finetuned_models": {- "description": "A fine-tuned model trained on your data.",- "docs_url": "https://docs.cohere.com/reference/listfinetunedmodels",- "columns": {- "id": "Unique identifier for the fine-tuned model.",- "name": "Human-readable name of the fine-tuned model.",- "creator_id": "The user that created the fine-tuned model.",- "organization_id": "The organization that owns the fine-tuned model.",- "settings": "The fine-tuning configuration (base model, hyperparameters, dataset).",- "status": "The lifecycle status of the fine-tuned model (e.g. STATUS_READY, STATUS_FAILED).",- "created_at": "Time at which the fine-tuned model was created.",- "updated_at": "Time at which the fine-tuned model was last updated.",- "completed_at": "Time at which fine-tuning completed.",- "last_used": "Time at which the fine-tuned model was last used.",- },- },"embed_jobs": {"description": "An asynchronous job that embeds a dataset into vectors.","docs_url": "https://docs.cohere.com/reference/list-embed-jobs",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/cohere.py b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/cohere.pyindex 6714ea853edc..6c1fdf7ff25c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/cohere.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/cohere.py@@ -2,6 +2,7 @@ from typing import Anyfrom products.warehouse_sources.backend.temporal.data_imports.sources.cohere.settings import (COHERE_ENDPOINTS,+ RETIRED_ENDPOINTS,CohereEndpointConfig,CoherePagination,)@@ -59,6 +60,10 @@ def cohere_source(team_id: int,job_id: str,) -> SourceResponse:+ retired_reason = RETIRED_ENDPOINTS.get(endpoint)+ if retired_reason is not None:+ raise ValueError(retired_reason)+config = COHERE_ENDPOINTS[endpoint]partitioned = config.partition_key is not Nonediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/settings.pyindex 4a6931be3845..4cad86dd4924 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/settings.py@@ -3,11 +3,11 @@ from enum import Enumclass CoherePagination(Enum):- # ?limit=&offset= — used by /datasets and /connectors. Terminate when a page returns- # fewer rows than the page size.+ # ?limit=&offset= — used by /datasets. Terminate when a page returns fewer rows than the+ # page size.OFFSET = "offset"- # ?page_size=&page_token= with a next_page_token in the body — used by /models and- # /finetuning/finetuned-models. Terminate when the response omits the token.+ # ?page_size=&page_token= with a next_page_token in the body — used by /models. Terminate+ # when the response omits the token.PAGE_TOKEN = "page_token"# Single unpaginated request returning every row — used by /embed-jobs.NONE = "none"@@ -39,12 +39,6 @@ COHERE_ENDPOINTS: dict[str, CohereEndpointConfig] = {data_key="datasets",pagination=CoherePagination.OFFSET,),- "connectors": CohereEndpointConfig(- name="connectors",- path="/connectors",- data_key="connectors",- pagination=CoherePagination.OFFSET,- ),# The model catalog has no per-model creation timestamp, so it can't be partitioned by one."models": CohereEndpointConfig(name="models",@@ -55,12 +49,6 @@ COHERE_ENDPOINTS: dict[str, CohereEndpointConfig] = {partition_key=None,page_size=1000, # /models caps page_size at 1000),- "finetuned_models": CohereEndpointConfig(- name="finetuned_models",- path="/finetuning/finetuned-models",- data_key="finetuned_models",- pagination=CoherePagination.PAGE_TOKEN,- ),"embed_jobs": CohereEndpointConfig(name="embed_jobs",path="/embed-jobs",@@ -70,4 +58,21 @@ COHERE_ENDPOINTS: dict[str, CohereEndpointConfig] = {),}+# Tables whose Cohere endpoint no longer exists. Dropping the name from COHERE_ENDPOINTS is what+# retires the table: schema discovery stops listing it, which disables syncing and leaves any+# already-imported rows in place. The reason lives here so a job that starts before the next+# discovery run explains itself rather than raising a KeyError.+# https://docs.cohere.com/docs/deprecations — the 2025-09-15 announcement retires connectors and+# all of fine-tuning across both the dashboard and the API. Both paths now answer 404.+RETIRED_ENDPOINTS: dict[str, str] = {+ "connectors": (+ "Cohere retired its connectors API on September 15, 2025, so the connectors table can't "+ "sync any more. Turn off syncing for this table."+ ),+ "finetuned_models": (+ "Cohere retired fine-tuning on September 15, 2025, so the finetuned models table can't "+ "sync any more. Turn off syncing for this table."+ ),+}+ENDPOINTS = tuple(COHERE_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/source.pyindex ab01f2250481..d80e2b1be15b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/source.py@@ -12,7 +12,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.cohcohere_source,validate_credentials as validate_cohere_credentials,)-from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.settings import ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.settings import (+ ENDPOINTS,+ RETIRED_ENDPOINTS,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (CanonicalDescriptions,@@ -28,10 +31,10 @@ from products.warehouse_sources.backend.types import ExternalDataSourceTypeclass CohereSource(SimpleSource[CohereSourceConfig]):lists_tables_without_credentials = True # static endpoint catalog — safe for public docs# Cohere's v2 generation adds no route for anything this source reads: its own v2 reference- # documents datasets, models, finetuned models, and embed jobs at /v1/ paths, and connectors has- # no v2 successor at all. A "v2" pin would therefore name a wire Cohere does not serve for these- # tables. v1 is not sunset either - the 2025-09-15 announcement retires individual endpoints- # (/v1/connectors here), not the version - so v1 stays supported and undeprecated.+ # documents datasets, models, and embed jobs at /v1/ paths. A "v2" pin would therefore name a+ # wire Cohere does not serve for these tables. v1 is not sunset either - the 2025-09-15+ # announcement retires individual endpoints, not the version - so v1 stays supported and+ # undeprecated.supported_versions = (COHERE_API_VERSION_V1,)default_version = COHERE_API_VERSION_V1api_docs_url = "https://docs.cohere.com/reference/about"@@ -83,6 +86,9 @@ Create an API key in your [Cohere dashboard](https://dashboard.cohere.com/api-ke# the stable status text and base host, not the per-request path/query."401 Client Error: Unauthorized for url: https://api.cohere.com": "Your Cohere API key is invalid or has been revoked. Create a new key in your Cohere dashboard, then reconnect.","403 Client Error: Forbidden for url: https://api.cohere.com": "Your Cohere API key is missing the permissions needed to sync this data. Check the key permissions in your Cohere dashboard, then reconnect.",+ # A schema created before the endpoint was retired keeps syncing until someone turns it+ # off, and no retry brings a removed route back.+ **{reason: reason for reason in RETIRED_ENDPOINTS.values()},}def get_schemas(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/tests/test_cohere.py b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/tests/test_cohere.pyindex 639ed4047b17..95d52a02c0d6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/tests/test_cohere.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/tests/test_cohere.py@@ -10,7 +10,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.cohcohere_source,validate_credentials,)-from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.settings import COHERE_ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.settings import (+ COHERE_ENDPOINTS,+ RETIRED_ENDPOINTS,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client import RESTClient# RESTClient builds its session via make_tracked_session in the rest_client module.@@ -104,32 +107,22 @@ class TestPageTokenPagination:params = _wire(session,[- _response("finetuned_models", [{"id": "a"}], extra={"next_page_token": "t2"}),- _response("finetuned_models", [{"id": "b"}]),+ _response("models", [{"name": "command"}], extra={"next_page_token": "t2"}),+ _response("models", [{"name": "embed"}]),],)- rows = _rows(cohere_source("key", "finetuned_models", team_id=1, job_id="j"))+ rows = _rows(cohere_source("key", "models", team_id=1, job_id="j"))- assert [r["id"] for r in rows] == ["a", "b"]+ assert [r["name"] for r in rows] == ["command", "embed"]# First request carries the page size but no token; the second carries the token from the- # first response. Absence of a token in the second response ends pagination.- assert params[0]["page_size"] == 100+ # first response. Absence of a token in the second response ends pagination. /models caps+ # page_size at 1000.+ assert params[0]["page_size"] == 1000assert "page_token" not in params[0]assert params[1]["page_token"] == "t2"assert session.send.call_count == 2- @mock.patch(CLIENT_SESSION_PATCH)- def test_models_uses_large_page_size(self, MockSession) -> None:- session = MockSession.return_value- params = _wire(session, [_response("models", [{"name": "command"}])])-- rows = _rows(cohere_source("key", "models", team_id=1, job_id="j"))-- assert [r["name"] for r in rows] == ["command"]- # /models caps page_size at 1000.- assert params[0]["page_size"] == 1000-class TestSinglePage:@mock.patch(CLIENT_SESSION_PATCH)@@ -226,3 +219,18 @@ class TestValidateCredentials:mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)validate_credentials("secret-key")assert mock_session.call_args.kwargs["redact_values"] == ("secret-key",)+++class TestRetiredEndpoints:+ @pytest.mark.parametrize("endpoint", sorted(RETIRED_ENDPOINTS))+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_retired_endpoint_explains_itself_without_calling_cohere(self, MockSession, endpoint: str) -> None:+ # Cohere removed both routes, so a request could only ever 404 and burn the retry budget of+ # a schema that was created while the endpoint still existed.+ session = MockSession.return_value+ _wire(session, [])++ with pytest.raises(ValueError, match="Turn off syncing for this table"):+ _rows(cohere_source("key", endpoint, team_id=1, job_id="j"))++ assert session.send.call_count == 0diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/tests/test_cohere_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/tests/test_cohere_source.pyindex 91768a7efd99..30f43a6f8a37 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/tests/test_cohere_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/cohere/tests/test_cohere_source.py@@ -7,7 +7,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.cohCOHERE_API_VERSION_V1,COHERE_BASE_URL,)-from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.settings import ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.settings import (+ ENDPOINTS,+ RETIRED_ENDPOINTS,+)from products.warehouse_sources.backend.temporal.data_imports.sources.cohere.source import CohereSourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.cohere import CohereSourceConfig@@ -34,6 +37,14 @@ class TestCohereSourceClass:schemas = self.source.get_schemas(_config(), team_id=self.team_id, names=["datasets"])assert [s.name for s in schemas] == ["datasets"]+ @parameterized.expand([(e,) for e in sorted(RETIRED_ENDPOINTS)])+ def test_retired_endpoint_is_off_the_catalog_and_stops_retrying(self, endpoint: str) -> None:+ # Discovery drops the table because it left COHERE_ENDPOINTS. A schema created before the+ # retirement keeps running until someone turns it off, so its failure has to be classified+ # non-retryable or every scheduled run burns the full retry budget on a removed route.+ assert endpoint not in ENDPOINTS+ assert RETIRED_ENDPOINTS[endpoint] in self.source.get_non_retryable_errors()+def test_lists_tables_without_credentials_for_public_docs(self) -> None:# get_schemas is a static catalog with no I/O, so the table list is safe to publish.assert self.source.lists_tables_without_credentials is True