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(uptimerobot): stop retrying scoped API keys hitting 403 on unauthorized endpoints (#76381)

Tom Owers55b755cd24f6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/source.py
index 84fc18095cc5..cfda08c12bf7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/source.py
@@ -84,6 +84,12 @@ Use your account's **read-only API key**, created under [Integrations & API](htt
# raises with this stable prefix when the API rejects the key. Retrying can never fix a
# credential problem, so stop the sync.
AUTH_ERROR_PREFIX: "Your UptimeRobot API key is invalid or has been revoked. Create a new read-only API key under Integrations & API in your UptimeRobot dashboard, then reconnect.",
+ # A monitor-specific API key is only scoped to one monitor, so getAlertContacts/getMWindows/
+ # getPSPs come back as a raw HTTP 403 (not an in-body {"stat": "fail"} error, so it bypasses
+ # AUTH_ERROR_PREFIX above and instead raises via response.raise_for_status()). Match the
+ # stable domain, not the per-request method in the URL path. Retrying can't grant a scoped
+ # key access it was never issued.
+ "403 Client Error: Forbidden for url: https://api.uptimerobot.com": "Your UptimeRobot API key doesn't have permission to sync this table. Monitor-specific API keys only grant access to a single monitor, so alert contacts, maintenance windows, and status pages won't sync with one. Reconnect with a full-account read-only API key under Integrations & API in your UptimeRobot dashboard.",
}
def get_retryable_errors(self) -> set[str]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/tests/test_uptimerobot_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/tests/test_uptimerobot_source.py
index 05ef418872cb..186c4df96dbe 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/tests/test_uptimerobot_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/tests/test_uptimerobot_source.py
@@ -3,6 +3,7 @@ from unittest import mock
from posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigType
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matches
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.uptimerobot import (
UptimerobotSourceConfig,
)
@@ -49,11 +50,21 @@ class TestUptimerobotSource:
assert api_key_field.secret is True
assert api_key_field.required is True
- def test_non_retryable_errors_match_transport_auth_failure(self):
- # UptimeRobot signals a bad key in-body over HTTP 200; the transport raises with this message.
- observed_error = "UptimeRobot API key was rejected: api_key is invalid."
+ @pytest.mark.parametrize(
+ "observed_error",
+ [
+ # UptimeRobot signals a bad key in-body over HTTP 200; the transport raises this message.
+ "UptimeRobot API key was rejected: api_key is invalid.",
+ # A monitor-specific key hitting a scope it isn't granted (e.g. maintenance windows)
+ # comes back as a raw HTTP 403, bypassing the in-body auth check entirely.
+ "403 Client Error: Forbidden for url: https://api.uptimerobot.com/v2/getMWindows",
+ "403 Client Error: Forbidden for url: https://api.uptimerobot.com/v2/getAlertContacts",
+ ],
+ )
+ def test_non_retryable_errors_match_credential_failures(self, observed_error):
+ # Mirrors the production matcher (`error_message_matches`), which is case-insensitive.
non_retryable_errors = self.source.get_non_retryable_errors()
- assert any(key in observed_error for key in non_retryable_errors)
+ assert error_message_matches(observed_error, non_retryable_errors)
@pytest.mark.parametrize(
"other_error",