: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(warehouse-sources): log the response body on an Etsy API error (#99398)
Tom Owersc5fd959f5fef
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/etsy/etsy.py b/products/warehouse_sources/backend/temporal/data_imports/sources/etsy/etsy.pyindex b6bd43c2bf75..f93109bdcc20 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/etsy/etsy.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/etsy/etsy.py@@ -120,7 +120,9 @@ class EtsyClient:response = self._send(path, params)if response.status_code >= 300:- self._logger.error(f"Etsy API error: status={response.status_code}, path={path}")+ self._logger.error(+ f"Etsy API error: status={response.status_code}, path={path}, body={response.text[:500]}"+ )response.raise_for_status()raise EtsyAPIError(f"Unexpected Etsy redirect response: status={response.status_code}, path={path}")diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/etsy/tests/test_etsy.py b/products/warehouse_sources/backend/temporal/data_imports/sources/etsy/tests/test_etsy.pyindex fc315e86508c..c0143d02e8a3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/etsy/tests/test_etsy.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/etsy/tests/test_etsy.py@@ -1,5 +1,6 @@import jsonimport time+import loggingfrom collections.abc import Iterable, Iteratorfrom typing import Any, Optional, cast@@ -195,6 +196,15 @@ class TestEtsyTransport:with pytest.raises(HTTPError):_collect(session, "shop_sections")+ def test_client_error_logs_the_response_body(self, caplog: pytest.LogCaptureFixture) -> None:+ # requests' raise_for_status() message carries only the status and URL, so the body is the+ # only place Etsy's actual rejection reason (e.g. an invalid parameter) survives to be triaged.+ session = _FakeSession([_response({"error": "invalid min_created"}, status=400)])+ with caplog.at_level(logging.ERROR), pytest.raises(HTTPError):+ _collect(session, "shop_sections")++ assert any("invalid min_created" in record.message for record in caplog.records)+def test_shop_id_is_discovered_when_not_configured(self) -> None:session = _FakeSession([_response({"user_id": 7, "shop_id": 4242}), _page(_rows(1), 1)])_collect(session, "shop_sections", shop_id=None)