Skip to content

: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.

fix(warehouse): stop retrying Mux invalid_timeframe 400s (#87534)

posthog[bot]e2425eddcb48
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mux/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mux/source.py
index 7f60d5bc03c3..68467a6486b7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mux/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mux/source.py
@@ -98,6 +98,16 @@ Grant the following read permissions:
# fixed by retrying. Match the stable status text and base host, not the per-request path.
"401 Client Error: Unauthorized for url: https://api.mux.com": "Your Mux access token is invalid or has been revoked. Create a new access token in your Mux dashboard, then reconnect.",
"403 Client Error: Forbidden for url: https://api.mux.com": "Your Mux access token is missing the read permissions needed to sync this data. Grant Mux Video, Mux Data and Mux System read access, then reconnect.",
+ # A Mux Data endpoint returns a 400 with `type: invalid_timeframe` when the requested
+ # `timeframe[]` window reaches past the history the account keeps. Mux Data retention
+ # depends on the plan, so the same window can succeed for one account and be rejected by
+ # another; the request never becomes valid on retry. The REST engine appends the Mux error
+ # `type` to the message as `code=invalid_timeframe`, so match that.
+ "code=invalid_timeframe": (
+ "Mux rejected the time range this sync requested as invalid. This usually means the range "
+ "reaches further back than your Mux plan keeps. Check your Mux Data retention window, or "
+ "contact PostHog support if this keeps happening."
+ ),
}
def get_schemas(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mux/tests/test_mux_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mux/tests/test_mux_source.py
index b4f125c3f149..909539931869 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mux/tests/test_mux_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mux/tests/test_mux_source.py
@@ -89,9 +89,16 @@ class TestMuxNonRetryableErrors:
[
("unauthorized", "401 Client Error: Unauthorized for url: https://api.mux.com/video/v1/assets?limit=100"),
("forbidden", "403 Client Error: Forbidden for url: https://api.mux.com/system/v1/signing-keys?limit=100"),
+ # The REST engine appends the Mux error `type` to the raise_for_status text as
+ # `code=invalid_timeframe` (see rest_client `_error_identity`). The window is fixed for the
+ # run, so retrying replays the same 400. The sync must stop and show a clear message instead.
+ (
+ "invalid_timeframe",
+ "400 Client Error: Bad Request for url: https://api.mux.com/data/v1/errors | api error: code=invalid_timeframe",
+ ),
]
)
- def test_credential_errors_are_non_retryable(self, _name: str, observed_error: str) -> None:
+ def test_deterministic_client_errors_are_non_retryable(self, _name: str, observed_error: str) -> None:
non_retryable = MuxSource().get_non_retryable_errors()
assert any(key in observed_error for key in non_retryable)