: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-imports): skip Anthropic workspaces that answer 400 for workspace_members (#107858)
Tom Owersee2e7f0797c2
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/anthropic.py b/products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/anthropic.pyindex fd8ceb5bfeb0..690f0f2c18e4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/anthropic.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/anthropic.py@@ -968,10 +968,15 @@ def anthropic_source("data_selector": config.data_selector,"paginator": _list_paginator(config),# A parent that does not serve this sub-resource, or that was archived or- # deleted between enumeration and the child fetch, answers 404. Skip that- # parent instead of failing the whole schema. 429/5xx are retried by the- # client before hooks run, and any other 4xx still raises.- "response_actions": [{"status_code": 404, "action": "ignore"}],+ # deleted between enumeration and the child fetch, answers 404 or 400 (the+ # organization's Default Workspace, for one, "has no member list of its own"+ # and answers 400 for workspace_members). Skip that parent instead of failing+ # the whole schema. 429/5xx are retried by the client before hooks run, and+ # any other 4xx still raises.+ "response_actions": [+ {"status_code": 404, "action": "ignore"},+ {"status_code": 400, "action": "ignore"},+ ],},"include_from_parent": ["id"],"data_map": fan_out_data_map,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/tests/test_anthropic.py b/products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/tests/test_anthropic.pyindex 57483b270804..d0f6a2740cb5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/tests/test_anthropic.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/tests/test_anthropic.py@@ -535,6 +535,25 @@ class TestWorkspaceMembersFanOut:assert [(r["workspace_id"], r["user_id"]) for r in rows] == [("wrkspc_2", "u2")]+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_workspace_with_no_member_list_of_its_own_is_skipped(self, MockSession) -> None:+ # The organization's Default Workspace "has no member list of its own" (Anthropic's own+ # words), and answers 400 rather than 404 for this sub-resource. Skip only that workspace+ # instead of failing the whole schema, same as the 404 case above.+ session = MockSession.return_value+ _wire(+ session,+ [+ _entity_page([{"id": "wrkspc_1"}, {"id": "wrkspc_2"}], has_more=False, last_id="wrkspc_2"),+ _response({"error": "bad_request"}, status=400),+ _entity_page([{"user_id": "u2", "workspace_id": "wrkspc_2"}], has_more=False, last_id="u2"),+ ],+ )++ rows = _rows(_source("workspace_members", _make_manager()))++ assert [(r["workspace_id"], r["user_id"]) for r in rows] == [("wrkspc_2", "u2")]+def test_saved_state_shapes_still_parse(self) -> None:# ResumableSourceManager._load_json does dataclass(**saved) — every historical shape must# keep parsing after the migration.