: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 6 missing tables to the LaunchDarkly source (#119924)
Tom Owers281406fdeb28
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 6943ddb92a0b..cff80bf9fc17 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@@ -7170,9 +7170,9 @@ Diffed against: <https://app.launchdarkly.com/api/v2/openapi.json>- [x] `GET /api/v2/segments/{projectKey}/{environmentKey}` — segments referenced by the flag targeting rules already synced - without them rule targets are unresolvable ids (high)- [x] `GET /api/v2/flag-statuses/{projectKey}/{environmentKey}` — per-flag status and last-requested timestamp, the basis for stale-flag and adoption reporting (high)- [x] `GET /api/v2/projects/{projectKey}/environments/{environmentKey}/holdouts` — holdout groups tied to experiment measurement (medium)-- [ ] `GET /api/v2/projects/{projectKey}/metric-groups` — lookup grouping the metrics already synced, and what experiments actually attach to (medium)-- [ ] `GET /api/v2/teams (+ /teams/{teamKey}/maintainers, /teams/{teamKey}/roles)` — team membership and maintainer mapping for the members table already synced (medium)-- [ ] `GET /api/v2/code-refs/statistics/{projectKey} and /api/v2/code-refs/repositories` — flag code-reference counts per repo - how you prove a flag is safe to remove (medium)+- [x] `GET /api/v2/projects/{projectKey}/metric-groups` — lookup grouping the metrics already synced, and what experiments actually attach to (medium)+- [x] `GET /api/v2/teams (+ /teams/{teamKey}/maintainers, /teams/{teamKey}/roles)` — team membership and maintainer mapping for the members table already synced (medium)+- [x] `GET /api/v2/code-refs/statistics/{projectKey} and /api/v2/code-refs/repositories` — flag code-reference counts per repo - how you prove a flag is safe to remove (medium)- [ ] `GET /api/v2/engineering-insights/flag-events` — flag change event stream, a real transition history to complement the audit log (medium)- [ ] `GET /api/v2/engineering-insights/deployments` — deployment records used for lead-time and release-frequency analysis (medium)- [ ] `GET /api/v2/approval-requests` — approval request lifecycle for flag changes - governance and change-velocity reporting (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/canonical_descriptions.pyindex 4b838744da31..34de39d0d149 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/canonical_descriptions.py@@ -169,4 +169,93 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"experiments": "The experiments that belong to the holdout.",},},+ "metric_groups": {+ "description": "A metric group: an ordered set of metrics that experiments and guarded rollouts measure together.",+ "docs_url": "https://apidocs.launchdarkly.com/tag/Metrics-(beta)",+ "columns": {+ "_project_key": "Key of the project this metric group belongs to (injected during sync).",+ "_id": "Unique identifier for the metric group.",+ "key": "The metric group's unique key.",+ "name": "The metric group's human-readable name.",+ "kind": "The type of the metric group: funnel or standard.",+ "description": "Description of the metric group.",+ "tags": "Tags applied to the metric group.",+ "maintainer": "The maintainer of the metric group.",+ "metrics": "The ordered list of metrics in the metric group.",+ "_creationDate": "Time the metric group was created, as an epoch-millisecond timestamp.",+ "_lastModified": "Time the metric group was last modified, as an epoch-millisecond timestamp.",+ "_version": "The version of the metric group.",+ "experimentCount": "The number of experiments that use the metric group.",+ "activeExperimentCount": "The number of active experiments that use the metric group.",+ "activeGuardedRolloutCount": "The number of active guarded rollouts that use the metric group.",+ },+ },+ "teams": {+ "description": "A team: a group of account members that share custom roles and maintain resources together.",+ "docs_url": "https://apidocs.launchdarkly.com/tag/Teams",+ "columns": {+ "key": "The team's unique key.",+ "name": "The team's human-readable name.",+ "description": "Description of the team.",+ "members": "The total count of members that belong to the team.",+ "roleAttributes": "The role attributes assigned to the team.",+ "_creationDate": "Time the team was created, as an epoch-millisecond timestamp.",+ "_lastModified": "Time the team was last modified, as an epoch-millisecond timestamp.",+ "_version": "The version of the team.",+ "_idpSynced": "Whether the team is synced with an external identity provider.",+ },+ },+ "team_maintainers": {+ "description": "An account member assigned as a maintainer of a team.",+ "docs_url": "https://apidocs.launchdarkly.com/tag/Teams",+ "columns": {+ "_team_key": "Key of the team this member maintains (injected during sync).",+ "_id": "Unique identifier of the member. Joins to members._id.",+ "email": "The member's email address.",+ "firstName": "The member's first name.",+ "lastName": "The member's last name.",+ "role": "The member's base role.",+ },+ },+ "team_roles": {+ "description": "A custom role assigned to a team.",+ "docs_url": "https://apidocs.launchdarkly.com/tag/Teams",+ "columns": {+ "_team_key": "Key of the team the custom role is assigned to (injected during sync).",+ "key": "The custom role's key.",+ "name": "The custom role's name.",+ "projects": "The projects where team members have write privileges through this role.",+ "appliedOn": "Time the custom role was assigned to the team, as an epoch-millisecond timestamp.",+ },+ },+ "code_ref_repositories": {+ "description": "A source code repository connected to LaunchDarkly code references.",+ "docs_url": "https://apidocs.launchdarkly.com/tag/Code-references",+ "columns": {+ "name": "The repository name.",+ "type": "The type of repository, for example github or gitlab.",+ "sourceLink": "A URL to access the repository.",+ "defaultBranch": "The repository's default branch.",+ "enabled": "Whether the repository is enabled for code references.",+ "version": "The version of the repository's saved information.",+ "branches": "The branches of the repository that have been scanned for flag references.",+ },+ },+ "code_ref_statistics": {+ "description": "The number of code references to a flag in one repository, on the repository's default branch.",+ "docs_url": "https://apidocs.launchdarkly.com/tag/Code-references",+ "columns": {+ "_project_key": "Key of the project the flag belongs to (injected during sync).",+ "_flag_key": "Key of the flag the references point to (injected during sync).",+ "name": "The repository name. Joins to code_ref_repositories.name.",+ "type": "The type of repository, for example github or gitlab.",+ "sourceLink": "A URL to access the repository.",+ "defaultBranch": "The repository's default branch.",+ "enabled": "Whether the repository is enabled for code references.",+ "version": "The version of the repository's saved information.",+ "hunkCount": "The number of code reference hunks in which the flag appears in the repository.",+ "fileCount": "The number of files in which the flag appears in the repository.",+ "latestCommitTime": "Time of the latest commit in the repository that includes the flag.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/launchdarkly.py b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/launchdarkly.pyindex 036ec2fa9cf1..056478b52175 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/launchdarkly.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/launchdarkly.py@@ -18,6 +18,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resBaseNextUrlPaginator,)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 EndpointResourcefrom 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@@ -35,6 +36,8 @@ BASE_URL = f"{API_HOST}/api/v2"PROJECTS_PARENT_NAME = "project"# Parent resource name for environment-scoped endpoints, injecting the environment key as `_environment_key`.ENVIRONMENTS_PARENT_NAME = "environment"+# Parent resource name for team-scoped endpoints, injecting the team key as `_team_key`.+TEAMS_PARENT_NAME = "team"@dataclasses.dataclass@@ -105,12 +108,25 @@ def _with_flag_key(row: dict[str, Any]) -> dict[str, Any]:return row-def _client_config(access_token: str) -> ClientConfig:+def _code_ref_statistic_rows(body: dict[str, Any]) -> list[dict[str, Any]]:+ # The statistics body maps each flag key to one statistic per repository that references the flag.+ flags = body.get("flags") or {}+ return [+ {**statistic, "_flag_key": flag_key, "_project_key": body.get("_project_key")}+ for flag_key, statistics in flags.items()+ for statistic in statistics or []+ ]+++def _client_config(access_token: str, beta: bool = False) -> ClientConfig:+ # Only non-secret headers go here; the access token rides on the framework auth so it's+ # scrubbed from any raised error message.+ headers = {"Accept": "application/json"}+ if beta:+ headers["LD-API-Version"] = "beta"return {"base_url": BASE_URL,- # Only the non-secret Accept header goes here; the access token rides on the framework auth- # so it's scrubbed from any raised error message.- "headers": {"Accept": "application/json"},+ "headers": headers,"auth": {"type": "api_key", "api_key": access_token, "name": "Authorization", "location": "header"},}@@ -124,14 +140,14 @@ def _build_toplevel_resource(resume: Optional[LaunchDarklyResumeConfig],) -> Resource:rest_config: RESTAPIConfig = {- "client": _client_config(access_token),+ "client": _client_config(access_token, beta=config.beta),"resources": [{"name": config.name,"endpoint": {"path": config.path,"params": _endpoint_params(config),- "data_selector": "items",+ "data_selector": config.data_selector,"paginator": LaunchDarklyLinkPaginator(),},}@@ -158,31 +174,54 @@ def _build_toplevel_resource()-def _project_fanout_config(config: LaunchDarklyEndpointConfig, access_token: str) -> RESTAPIConfig:+def _fanout_config(config: LaunchDarklyEndpointConfig, access_token: str, team_id: int, job_id: str) -> RESTAPIConfig:+ if config.requires_team:+ parent_name, parent_endpoint, path_param = TEAMS_PARENT_NAME, LAUNCHDARKLY_ENDPOINTS["teams"], "team_key"+ else:+ parent_name, parent_endpoint, path_param = (+ PROJECTS_PARENT_NAME,+ LAUNCHDARKLY_ENDPOINTS["projects"],+ "project_key",+ )++ parent: EndpointResource = {+ "name": parent_name,+ "endpoint": {+ "path": parent_endpoint.path,+ "params": {"limit": parent_endpoint.page_size},+ "data_selector": "items",+ "paginator": LaunchDarklyLinkPaginator(),+ },+ }+ if config.beta:+ # One client serves both resources, so the GA parent is listed by its own client to keep the+ # beta header off its requests.+ parent_rows = rest_api_resource(+ {"client": _client_config(access_token), "resources": [parent]}, team_id, job_id, None+ )+ parent = {+ "name": parent_name,+ # The iterator supplies the rows; the path is never requested.+ "endpoint": {"path": parent_endpoint.path},+ "data_iterator": lambda: iter(parent_rows),+ }+return {- "client": _client_config(access_token),+ "client": _client_config(access_token, beta=config.beta),"resources": [- {- "name": PROJECTS_PARENT_NAME,- "endpoint": {- "path": "/projects",- "params": {"limit": LAUNCHDARKLY_ENDPOINTS["projects"].page_size},- "data_selector": "items",- "paginator": LaunchDarklyLinkPaginator(),- },- },+ parent,{"name": config.name,"endpoint": {"path": config.path,"params": {- "project_key": {"type": "resolve", "resource": PROJECTS_PARENT_NAME, "field": "key"},+ path_param: {"type": "resolve", "resource": parent_name, "field": "key"},**_endpoint_params(config),},- "data_selector": "items",+ "data_selector": config.data_selector,"paginator": LaunchDarklyLinkPaginator(),},- # Injects the parent project's key into every child row as `_project_key`.+ # Injects the parent's key into every child row as `_project_key` or `_team_key`."include_from_parent": ["key"],},],@@ -205,14 +244,17 @@ def _build_fanout_resource(resumable_source_manager.save_state(LaunchDarklyResumeConfig(fanout_state=state))resources = rest_api_resources(- _project_fanout_config(config, access_token),+ _fanout_config(config, access_token, team_id, job_id),team_id,job_id,None,resume_hook=save_checkpoint,initial_paginator_state=initial_paginator_state,)- return next(resource for resource in resources if resource.name == config.name)+ resource = next(resource for resource in resources if resource.name == config.name)+ if config.name == "code_ref_statistics":+ resource.add_map(_code_ref_statistic_rows)+ return resourcedef _build_environment_fanout_resource(@@ -229,7 +271,7 @@ def _build_environment_fanout_resource(environments = next(resourcefor resource in rest_api_resources(- _project_fanout_config(environments_config, access_token), team_id, job_id, None+ _fanout_config(environments_config, access_token, team_id, job_id), team_id, job_id, None)if resource.name == environments_config.name)@@ -301,7 +343,7 @@ def launchdarkly_source(resource = _build_environment_fanout_resource(config, access_token, team_id, job_id, resumable_source_manager, resume)- elif config.requires_project:+ elif config.requires_project or config.requires_team:resource = _build_fanout_resource(config, access_token, team_id, job_id, resumable_source_manager, resume)else:resource = _build_toplevel_resource(config, access_token, team_id, job_id, resumable_source_manager, resume)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/settings.pyindex 4d6f0403813e..0e050b65af23 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/settings.py@@ -18,11 +18,17 @@ class LaunchDarklyEndpointConfig:# queried once per environment of every project, with ``_project_key`` and ``_environment_key``# injected into every row.requires_environment: bool = False+ # Team-scoped endpoints take a ``{team_key}`` placeholder and are queried once per team, with+ # ``_team_key`` injected into every row.+ requires_team: bool = False+ # Beta resources answer 403 unless every request carries ``LD-API-Version: beta``.+ beta: bool = False# LaunchDarkly's list endpoints default to a small page size; 20 is the documented# safe default across every endpoint we sync. Raise per-endpoint only once verified.# ``None`` for endpoints that return every row in one response and take no ``limit``.page_size: int | None = 20extra_params: dict[str, Any] = field(default_factory=dict)+ data_selector: str = "items"# LaunchDarkly exposes no server-side timestamp filter on these resources (its# timestamps are epoch-millisecond integers and the public API offers no# ``updated_after``/``since`` parameter), so every endpoint is full-refresh only.@@ -97,6 +103,48 @@ LAUNCHDARKLY_ENDPOINTS: dict[str, LaunchDarklyEndpointConfig] = {primary_key=["_id", "_project_key", "_environment_key"],requires_environment=True,),+ "metric_groups": LaunchDarklyEndpointConfig(+ name="metric_groups",+ path="/projects/{project_key}/metric-groups",+ primary_key=["_id", "_project_key"],+ requires_project=True,+ beta=True,+ ),+ "teams": LaunchDarklyEndpointConfig(+ name="teams",+ path="/teams",+ primary_key=["key"],+ extra_params={"expand": "members,roleAttributes"},+ ),+ "team_maintainers": LaunchDarklyEndpointConfig(+ name="team_maintainers",+ path="/teams/{team_key}/maintainers",+ # A member can maintain several teams, so the member id alone repeats across teams.+ primary_key=["_id", "_team_key"],+ requires_team=True,+ ),+ "team_roles": LaunchDarklyEndpointConfig(+ name="team_roles",+ path="/teams/{team_key}/roles",+ primary_key=["key", "_team_key"],+ requires_team=True,+ ),+ "code_ref_repositories": LaunchDarklyEndpointConfig(+ name="code_ref_repositories",+ path="/code-refs/repositories",+ primary_key=["name"],+ page_size=None,+ extra_params={"withBranches": "true"},+ ),+ "code_ref_statistics": LaunchDarklyEndpointConfig(+ name="code_ref_statistics",+ path="/code-refs/statistics/{project_key}",+ # One row per flag and repository; rows are flattened out of the response's flag-key map.+ primary_key=["_flag_key", "name", "_project_key"],+ requires_project=True,+ page_size=None,+ data_selector="$",+ ),}ENDPOINTS = tuple(LAUNCHDARKLY_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/source.pyindex 2be7573a6dfc..9b2a4b693053 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/source.py@@ -230,7 +230,7 @@ class LaunchDarklySource(ResumableSource[LaunchDarklySourceConfig, LaunchDarklyRkeywords=["feature flags"],label="LaunchDarkly",releaseStatus=ReleaseStatus.ALPHA,- caption="""Enter your LaunchDarkly access token to pull your projects, environments, feature flags, flag statuses, segments, experiments, holdouts, metrics, members, and audit log into the PostHog Data warehouse.+ caption="""Enter your LaunchDarkly access token to pull your projects, environments, feature flags, flag statuses, segments, experiments, holdouts, metrics, metric groups, members, teams, code references, and audit log into the PostHog Data warehouse.You can create a personal or service access token in your [LaunchDarkly account settings](https://app.launchdarkly.com/settings/authorization). A token with the **Reader** role grants read access to every resource this source syncs.""",iconPath="/static/services/launchdarkly.png",@@ -295,15 +295,18 @@ You can create a personal or service access token in your [LaunchDarkly accountschema_name: Optional[str] = None,api_version: str | None = None,) -> tuple[bool, str | None]:- # Fan-out endpoints can't be probed without a project key, so confirm scope against- # /projects (their prerequisite); top-level endpoints probe their own path.+ # Fan-out endpoints can't be probed without a parent key, so confirm scope against their+ # parent list (/projects or /teams); top-level endpoints probe their own path.probe_path = "/caller-identity"if schema_name is not None:endpoint = LAUNCHDARKLY_ENDPOINTS.get(schema_name)if endpoint is not None:- probe_path = (- "/projects" if endpoint.requires_project or endpoint.requires_environment else endpoint.path- )+ if endpoint.requires_team:+ probe_path = "/teams"+ elif endpoint.requires_project or endpoint.requires_environment:+ probe_path = "/projects"+ else:+ probe_path = endpoint.pathstatus = validate_launchdarkly_credentials(config.access_token, probe_path)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/tests/test_launchdarkly.py b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/tests/test_launchdarkly.pyindex e6267473f310..289d0ccd9801 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/tests/test_launchdarkly.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/tests/test_launchdarkly.py@@ -84,22 +84,55 @@ class TestGetRowsTopLevel:class TestGetRowsFanout:- def test_iterates_projects_and_injects_project_key(self) -> None:+ @pytest.mark.parametrize(+ "endpoint, parent_path, child_paths, injected_key, beta",+ [+ (+ "environments",+ "/api/v2/projects",+ ["/api/v2/projects/p1/environments", "/api/v2/projects/p2/environments"],+ "_project_key",+ False,+ ),+ (+ "metric_groups",+ "/api/v2/projects",+ ["/api/v2/projects/p1/metric-groups", "/api/v2/projects/p2/metric-groups"],+ "_project_key",+ True,+ ),+ (+ "team_maintainers",+ "/api/v2/teams",+ ["/api/v2/teams/p1/maintainers", "/api/v2/teams/p2/maintainers"],+ "_team_key",+ False,+ ),+ (+ "team_roles",+ "/api/v2/teams",+ ["/api/v2/teams/p1/roles", "/api/v2/teams/p2/roles"],+ "_team_key",+ False,+ ),+ ],+ )+ def test_iterates_parents_and_injects_parent_key(+ self, endpoint: str, parent_path: str, child_paths: list[str], injected_key: str, beta: bool+ ) -> None:result = _driver().run(- "environments",- [_page([{"key": "proj1"}, {"key": "proj2"}]), _page([{"_id": "e1"}]), _page([{"_id": "e2"}])],+ endpoint,+ [_page([{"key": "p1"}, {"key": "p2"}]), _page([{"_id": "c1"}]), _page([{"_id": "c2"}])],)assert result.raised is None- assert result.rows == [- {"_id": "e1", "_project_key": "proj1"},- {"_id": "e2", "_project_key": "proj2"},- ]- assert result.paths == [- "/api/v2/projects",- "/api/v2/projects/proj1/environments",- "/api/v2/projects/proj2/environments",- ]+ assert result.rows == [{"_id": "c1", injected_key: "p1"}, {"_id": "c2", injected_key: "p2"}]+ assert result.paths == [parent_path, *child_paths]+ # Beta resources 403 without the header, and the GA parent list must not be sent to the beta API.+ assert result.requests[0].headers.get("ld-api-version") is None+ assert [request.headers.get("ld-api-version") for request in result.requests[1:]] == (+ ["beta", "beta"] if beta else [None, None]+ )def test_resume_midproject_uses_saved_url(self) -> None:resume_url = f"{BASE_URL}/projects/proj1/environments?limit=20&offset=20"@@ -187,6 +220,40 @@ class TestGetRowsEnvironmentFanout:assert result.requests[2].url == resume_url+class TestCodeRefStatistics:+ @pytest.mark.parametrize(+ "flags, expected",+ [+ (+ {+ "flag-a": [{"name": "repo-1", "hunkCount": 3}, {"name": "repo-2", "hunkCount": 1}],+ "flag-b": [{"name": "repo-1", "hunkCount": 7}],+ },+ [+ {"name": "repo-1", "hunkCount": 3, "_flag_key": "flag-a", "_project_key": "proj1"},+ {"name": "repo-2", "hunkCount": 1, "_flag_key": "flag-a", "_project_key": "proj1"},+ {"name": "repo-1", "hunkCount": 7, "_flag_key": "flag-b", "_project_key": "proj1"},+ ],+ ),+ ({"flag-a": [], "flag-b": None}, []),+ ({}, []),+ (None, []),+ ],+ )+ def test_flattens_flag_map_into_one_row_per_flag_and_repository(+ self, flags: dict[str, Any] | None, expected: list[dict[str, Any]]+ ) -> None:+ result = _driver().run(+ "code_ref_statistics",+ [_page([{"key": "proj1"}]), ScriptedResponse(json={"flags": flags, "_links": {}})],+ )++ assert result.raised is None+ assert result.rows == expected+ assert result.requests[1].path == "/api/v2/code-refs/statistics/proj1"+ assert result.requests[1].param("limit") is None++class TestRetryAndErrors:def test_4xx_raises(self) -> None:result = _driver().run("members", [ScriptedResponse(status=403, json={"items": []})])diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/tests/test_launchdarkly_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/tests/test_launchdarkly_source.pyindex 1b71d6252d90..357d74df1abc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/tests/test_launchdarkly_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/launchdarkly/tests/test_launchdarkly_source.py@@ -18,26 +18,27 @@ class TestLaunchDarklySource:self.config = LaunchDarklySourceConfig(access_token="api-token")@pytest.mark.parametrize(- "status, schema_name, expected_valid",+ "status, schema_name, expected_valid, expected_probe",[- (200, None, True),- (401, None, False),+ (200, None, True, "/api/v2/caller-identity"),+ (401, None, False, "/api/v2/caller-identity"),# A valid token may lack scope for an unselected endpoint — accept 403 at source-create.- (403, None, True),+ (403, None, True, "/api/v2/caller-identity"),# But reject 403 when validating a specific schema.- (403, "flags", False),- (500, None, False),- (None, None, False),+ (403, "flags", False, "/api/v2/projects"),+ (403, "team_roles", False, "/api/v2/teams"),+ (200, "team_maintainers", True, "/api/v2/teams"),+ (200, "code_ref_repositories", True, "/api/v2/code-refs/repositories"),+ (500, None, False, "/api/v2/caller-identity"),+ (None, None, False, "/api/v2/caller-identity"),],)def test_validate_credentials_status_mapping(- self, status: int | None, schema_name: str | None, expected_valid: bool+ self, status: int | None, schema_name: str | None, expected_valid: bool, expected_probe: str) -> None:answer = ConnectionError("unreachable") if status is None else ScriptedResponse(status=status)with scripted_network(always(answer)) as network:is_valid, _error = self.source.validate_credentials(self.config, self.team_id, schema_name=schema_name)assert is_valid is expected_valid- assert {request.path for request in network.requests_log} == {- "/api/v2/projects" if schema_name == "flags" else "/api/v2/caller-identity"- }+ assert {request.path for request in network.requests_log} == {expected_probe}