: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(openai): stop fanning out project resources over archived projects (#100057)
Tom Owers5940e3287ee3
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/openai/openai.py b/products/warehouse_sources/backend/temporal/data_imports/sources/openai/openai.pyindex c451fbcb2b8d..7ca290f83cbe 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/openai/openai.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/openai/openai.py@@ -361,9 +361,11 @@ def openai_source(resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else Noneif config.fan_out_over_projects:- # Project-scoped resources have no org-wide list endpoint; enumerate every project (archived- # included, since they are still referenced by historical usage/cost rows) and fetch the- # resource per project.+ # Project-scoped resources have no org-wide list endpoint; enumerate the projects and fetch+ # the resource per project. Archived ones are left out: OpenAI rejects every project-scoped+ # read under an archived project, which would fail the whole schema on the first one. The+ # `projects` table keeps them (see its `extra_params`) so historical usage/cost rows still+ # resolve their project.projects_config = OPENAI_ENDPOINTS["projects"]rest_config: RESTAPIConfig = {"client": client_config,@@ -373,7 +375,7 @@ def openai_source("name": "projects","endpoint": {"path": projects_config.path,- "params": {"limit": ENTITY_PAGE_SIZE, **projects_config.extra_params},+ "params": {"limit": ENTITY_PAGE_SIZE},"data_selector": "data","paginator": _EntityPaginator(),},diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/openai/tests/test_openai.py b/products/warehouse_sources/backend/temporal/data_imports/sources/openai/tests/test_openai.pyindex d1c5017db376..a661d5efda74 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/openai/tests/test_openai.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/openai/tests/test_openai.py@@ -458,7 +458,9 @@ class TestProjectFanOut:# The framework's parent-key column must not leak into the row shape.assert all("_projects_id" not in r for r in rows)assert params[0]["url"].endswith("/v1/organization/projects")- assert params[0]["params"]["include_archived"] == "true"+ # OpenAI rejects a project-scoped read under an archived project, which would fail the+ # whole schema, so the fan-out must not ask for archived projects.+ assert "include_archived" not in params[0]["params"]assert params[1]["url"].endswith("/v1/organization/projects/proj_1/users")assert params[2]["url"].endswith("/v1/organization/projects/proj_2/users")