: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): treat Fly.io 400 Bad Request as non-retryable (#71727)
Tom Owers4edb7d092ab5
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/source.pyindex b745cf1ae62f..5b2af7c8e968 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/source.py@@ -95,6 +95,12 @@ Create an organization-scoped token with `fly tokens create org` (or from the **# the sync. Match the stable status text and base host, not the per-request path."401 Client Error: Unauthorized for url: https://api.machines.dev": "Your Fly.io API token is invalid or expired. Create a new token with `fly tokens create org` and reconnect.","403 Client Error: Forbidden for url: https://api.machines.dev": "Your Fly.io API token does not have access to this organization or resource. Check the token's scope and reconnect.",+ # Fly.io accepts the token (auth is checked before anything else, so a bad token is a+ # 401/403 handled above) but rejects the request itself. The org slug validates against+ # the apps endpoint yet the org-scoped machines/volumes endpoints refuse it, so the+ # request is deterministically bad and retrying just resends it. Match the stable status+ # text and base host, not the per-request path (which carries the org slug).+ "400 Client Error: Bad Request for url: https://api.machines.dev": "Fly.io rejected the request for this organization. Check that the organization slug is correct (find it with `fly orgs list`) and that your token can access that organization, then reconnect.",}def get_schemas(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io_source.pyindex 51df60d96c13..f27ea5570a58 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fly_io/tests/test_fly_io_source.py@@ -104,6 +104,12 @@ class TestNonRetryableErrors:[("unauthorized", "401 Client Error: Unauthorized for url: https://api.machines.dev/v1/orgs/acme/machines"),("forbidden", "403 Client Error: Forbidden for url: https://api.machines.dev/v1/apps?org_slug=acme"),+ # A 400 on the org-scoped machines/volumes endpoint is a permanent rejection (auth passed,+ # since a bad token is a 401/403); retrying resends the same doomed request.+ (+ "bad_request",+ "400 Client Error: Bad Request for url: https://api.machines.dev/v1/orgs/acme/machines?limit=1000",+ ),])def test_credential_errors_are_non_retryable(self, _name: str, observed_error: str) -> None: