: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): stop retrying PayMongo refunds rejected as invalid (#126320)
Tom Owersa6da3e6ceae0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/source.pyindex c81735e7f553..c858166fa6b8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/source.py@@ -116,6 +116,16 @@ class PaymongoSource(ResumableSource[PaymongoSourceConfig, PaymongoResumeConfig]return {"401 Client Error: Unauthorized": "PayMongo rejected your API key. Replace the invalid or expired key and reconnect.","403 Client Error: Forbidden": "Your PayMongo API key cannot access this table. Check your account permissions.",+ # PayMongo sometimes rejects the refunds filter for a specific payment (e.g.+ # code=parameter_invalid). The payment ID is baked into the path, not a query param, and+ # a paginated/resumed page appends a cursor param after the limit — so matching exact query+ # text would miss later pages. Match the path prefix instead: it is unique to this endpoint+ # among the source's resources and identical on every page, and any 4xx PayMongo gives for+ # one payment's refunds filter is a verdict on that payment, not our request.+ "api.paymongo.com/v1/refunds?data.attributes.payment_id=": (+ "PayMongo rejected the refunds filter for one of your payments. "+ "That payment's refunds can't be imported; check the payment in your PayMongo dashboard."+ ),}def get_schemas(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/tests/test_paymongo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/tests/test_paymongo.pyindex dfccdc59799b..e2362ed02a06 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/tests/test_paymongo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/paymongo/tests/test_paymongo.py@@ -162,6 +162,23 @@ def test_refund_fanout_keeps_payment_and_child_cursors() -> None:][email protected]("on_first_page", [True, False])+def test_refund_parameter_invalid_is_non_retryable(on_first_page: bool) -> None:+ script = [+ ScriptedResponse(json={"data": [row("pay_one")], "has_more": False}),+ ScriptedResponse(status=400, json={"errors": [{"code": "parameter_invalid"}]})+ if on_first_page+ else ScriptedResponse(json={"data": [row("ref_one")], "has_more": True}),+ ]+ if not on_first_page:+ # A later/resumed page appends a cursor param after the limit; the match must not depend+ # on query param ordering.+ script.append(ScriptedResponse(status=400, json={"errors": [{"code": "parameter_invalid"}]}))+ result = driver().run("refunds", script)+ assert isinstance(result.raised, HTTPError)+ assert any(pattern in str(result.raised) for pattern in PaymongoSource().get_non_retryable_errors())++def test_payout_transaction_fanout_keys_rows_by_payout() -> None:result = driver().run("payout_transactions",