: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
feat(data-warehouse): add 3 missing tables to the Uptimerobot source (#124536)
Tom Owers1067ac16d016
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex 628a0361db5d..52d1158a6500 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -1126,8 +1126,6 @@1 products/warehouse_sources/backend/temporal/data_imports/sources/unleash/unleash.py1 products/warehouse_sources/backend/temporal/data_imports/sources/uppromote/uppromote.py1 products/warehouse_sources/backend/temporal/data_imports/sources/upstash/settings.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/settings.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/uptimerobot.py1 products/warehouse_sources/backend/temporal/data_imports/sources/usersnap/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/usersnap/usersnap.py1 products/warehouse_sources/backend/temporal/data_imports/sources/uservoice/settings.pydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 8cd28bfed7ba..bbfe2e548b73 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -12825,10 +12825,10 @@ Today (6): `alert_contacts`, `maintenance_windows`, `monitor_logs`, `monitors`,Diffed against: <https://cdn.uptimerobot.com/api/openapi.yaml>-- [ ] `GET /incidents` — the downtime incident record — the headline analytical object for uptime reporting (high)+- [x] `GET /incidents` — the downtime incident record — the headline analytical object for uptime reporting (high)- [ ] `GET /monitors/uptime-stats and GET /monitors/{id}/stats/uptime` — uptime percentage / SLA metric, the vendor's headline number (high)-- [ ] `GET /monitor-groups` — lookup resolving the groupId carried on monitors we already sync (high)-- [ ] `GET /tags` — lookup resolving tag ids on monitors; the main breakdown dimension (high)+- [x] `GET /monitor-groups` — lookup resolving the groupId carried on monitors we already sync (high)+- [x] `GET /tags` — lookup resolving tag ids on monitors; the main breakdown dimension (high)- [ ] `GET /incidents/{id}/alerts` — which alert contacts were notified and when, per incident (medium)- [ ] `GET /incidents/{id}/activity-log` — state-transition history of an incident (acknowledge, resolve, escalate) (medium)- [ ] `GET /incidents/{id}/comments` — human annotations on incidents, useful for postmortem analysis (low)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/canonical_descriptions.pyindex 67faa9fa3f5f..33e862aeaafa 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/canonical_descriptions.py@@ -3,6 +3,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.can)_DOCS_URL = "https://uptimerobot.com/api/"+_V3_DOCS_URL = "https://uptimerobot.com/api/v3/"CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"monitors": {@@ -81,4 +82,39 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"status": "Status page status: 0 = paused, 1 = active.",},},+ "incidents": {+ "description": "Downtime incidents across the account's monitors, one row per incident.",+ "docs_url": _V3_DOCS_URL,+ "columns": {+ "id": "Unique identifier of the incident.",+ "status": "Current status of the incident, for example whether it is still ongoing or resolved.",+ "type": "Type of the incident.",+ "cause": "Numeric code of the cause of the incident, if known.",+ "reason": "Human-readable reason for the incident.",+ "monitor": "The affected monitor, as an object with its id and friendlyName.",+ "commentsCount": "Number of comments on the incident.",+ "startedAt": "When the incident started.",+ "resolvedAt": "When the incident was resolved. Empty while the incident is ongoing.",+ "duration": "Duration of the incident, in seconds. Empty while the incident is ongoing.",+ "includeInReports": "Whether the incident counts toward uptime reports.",+ },+ },+ "monitor_groups": {+ "description": "Groups that organize monitors. Resolves the group id carried on each monitor.",+ "docs_url": _V3_DOCS_URL,+ "columns": {+ "id": "Unique identifier of the monitor group.",+ "name": "Name of the monitor group.",+ "createdAt": "When the monitor group was created.",+ "updatedAt": "When the monitor group was last updated.",+ },+ },+ "tags": {+ "description": "Tags that label monitors. Resolves the tag ids carried on each monitor.",+ "docs_url": _V3_DOCS_URL,+ "columns": {+ "id": "Unique identifier of the tag.",+ "name": "Name of the tag.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/settings.pyindex 0d7a048c13ca..4f45b845dd13 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/settings.py@@ -1,10 +1,14 @@-from dataclasses import dataclass, field+from dataclasses import fieldfrom typing import Literal, Optional+from posthog.dataclasses import frozen+from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType# UptimeRobot v2 caps `limit` at 50 on every paginated list endpoint.PAGE_LIMIT = 50+# v3 list endpoints that take `limit` cap it at 200.+V3_PAGE_LIMIT = 200# UptimeRobot rejects response-time windows wider than 7 days, so history is walked in 7-day chunks.RESPONSE_TIMES_WINDOW_DAYS = 7@@ -25,14 +29,18 @@ def _datetime_incremental_fields() -> list[IncrementalField]:]-@dataclass+@frozenclass UptimeRobotEndpointConfig:name: str# v2 API method (e.g. "getMonitors"). Every v2 call is a form-encoded POST with the api_key in- # the body — there are no plain GET endpoints.+ # the body — there are no plain GET endpoints. For v3 endpoints this is the REST path (e.g. "/tags").method: str# Key in the response JSON holding the row list ("monitors", "alert_contacts", "mwindows", "psps").response_key: str+ # Some tables only exist on the v3 REST API: a bearer-authenticated GET with cursor pagination.+ api_version: Literal["v2", "v3"] = "v2"+ # v3 only: whether the endpoint accepts a `limit` page-size param.+ v3_accepts_limit: bool = Falseprimary_keys: list[str] = field(default_factory=lambda: ["id"])# Stable datetime-ish field to partition by (Unix epoch int). None disables partitioning.partition_key: Optional[str] = None@@ -106,6 +114,30 @@ UPTIMEROBOT_ENDPOINTS: dict[str, UptimeRobotEndpointConfig] = {method="getPSPs",response_key="psps",),+ # Incidents change after they start (an open incident gets a resolvedAt and duration later), and+ # the only server-side filter is on startedAt, so an incremental sync would never pick up the+ # resolution. Full refresh every run.+ "incidents": UptimeRobotEndpointConfig(+ name="incidents",+ method="/incidents",+ response_key="data",+ api_version="v3",+ partition_key="startedAt",+ ),+ "monitor_groups": UptimeRobotEndpointConfig(+ name="monitor_groups",+ method="/monitor-groups",+ response_key="data",+ api_version="v3",+ v3_accepts_limit=True,+ ),+ "tags": UptimeRobotEndpointConfig(+ name="tags",+ method="/tags",+ response_key="data",+ api_version="v3",+ v3_accepts_limit=True,+ ),}ENDPOINTS = tuple(UPTIMEROBOT_ENDPOINTS.keys())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.pyindex f6c279057572..d604f895cbcf 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@@ -53,7 +53,7 @@ class UptimerobotSource(ResumableSource[UptimerobotSourceConfig, UptimeRobotResureleaseStatus=ReleaseStatus.GA,caption="""Enter your UptimeRobot API key to pull your uptime monitoring data into the PostHog Data warehouse.-Use your account's **read-only API key**, created under [Integrations & API](https://dashboard.uptimerobot.com/integrations) in your UptimeRobot dashboard. Monitor-specific API keys only grant access to a single monitor, so the alert contacts, maintenance windows, and status pages tables won't sync with one.""",+Use your account's **read-only API key**, created under [Integrations & API](https://dashboard.uptimerobot.com/integrations) in your UptimeRobot dashboard. Monitor-specific API keys only grant access to a single monitor, so only the monitors, monitor logs, and response times tables sync with one.""",iconPath="/static/services/uptimerobot.png",docsUrl="https://posthog.com/docs/cdp/sources/uptimerobot",keywords=["uptime", "monitoring"],@@ -86,11 +86,12 @@ Use your account's **read-only API key**, created under [Integrations & API](htt# 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+ # getPSPs and the v3 endpoints 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.",+ "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 only the monitors, monitor logs, and response times tables sync with one. Monitor groups also need an UptimeRobot plan that includes them. 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.py b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/tests/test_uptimerobot.pyindex a023c5cca021..c2e213486b1d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/tests/test_uptimerobot.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/tests/test_uptimerobot.py@@ -4,23 +4,35 @@ from typing import Anyimport pytestfrom unittest.mock import MagicMock+import requestsfrom parameterized import parameterized+from products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (+ ScriptedResponse,+ SourceDriver,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.uptimerobot import (+ UptimerobotSourceConfig,+)from products.warehouse_sources.backend.temporal.data_imports.sources.uptimerobot import uptimerobotfrom products.warehouse_sources.backend.temporal.data_imports.sources.uptimerobot.settings import (PAGE_LIMIT,RESPONSE_TIMES_INITIAL_LOOKBACK_DAYS,)+from products.warehouse_sources.backend.temporal.data_imports.sources.uptimerobot.source import UptimerobotSourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.uptimerobot.uptimerobot import (AUTH_ERROR_PREFIX,+ MAX_RETRY_AFTER_SECONDS,UptimeRobotAPIError,UptimeRobotAuthError,UptimeRobotResumeConfig,UptimeRobotRetryableError,+ _get_v3,_next_offset,_post,_scrub_alert_contact,_to_unix_timestamp,+ _wait_v3,get_rows,uptimerobot_source,)@@ -139,6 +151,45 @@ class TestPost:self._call(_response(status_code=status_code))+class TestGetV3RetryAfter:+ @staticmethod+ def _raised(status_code: int, headers: dict[str, str]) -> UptimeRobotRetryableError:+ response = _response(status_code=status_code)+ response.headers = headers+ session = MagicMock()+ session.get.return_value = response+ with pytest.raises(UptimeRobotRetryableError) as excinfo:+ _get_v3.__wrapped__(session, "/tags", {}, MagicMock()) # type: ignore[attr-defined]+ return excinfo.value++ @staticmethod+ def _wait_after(exc: Exception) -> float:+ retry_state = MagicMock()+ retry_state.attempt_number = 1+ retry_state.outcome.exception.return_value = exc+ return _wait_v3(retry_state)++ @parameterized.expand(+ [+ ("seconds", 429, {"Retry-After": "42"}, 42.0),+ ("missing_header", 429, {}, None),+ ("http_date_falls_back", 429, {"Retry-After": "Wed, 21 Oct 2015 07:28:00 GMT"}, None),+ ("server_error_ignores_header", 503, {"Retry-After": "42"}, None),+ ]+ )+ def test_parses_retry_after(+ self, _name: str, status_code: int, headers: dict[str, str], expected: float | None+ ) -> None:+ assert self._raised(status_code, headers).retry_after == expected++ def test_wait_honors_retry_after_up_to_the_cap(self) -> None:+ assert self._wait_after(UptimeRobotRetryableError("x", retry_after=42)) == 42+ assert self._wait_after(UptimeRobotRetryableError("x", retry_after=600)) == MAX_RETRY_AFTER_SECONDS++ def test_wait_falls_back_to_backoff_without_retry_after(self) -> None:+ assert self._wait_after(UptimeRobotRetryableError("x")) <= 30++class _FakeResumableManager:def __init__(self, state: UptimeRobotResumeConfig | None = None) -> None:self._state = state@@ -373,3 +424,116 @@ class TestSourceResponseWiring:# Fan-out endpoints must defer the incremental watermark to job end ("desc"): batches# aggregate across monitor pages and time windows, so per-batch maxima aren't safe.assert response.sort_mode == sort_mode+++class TestV3Rows:+ @staticmethod+ def _driver() -> SourceDriver:+ return SourceDriver(UptimerobotSource(), UptimerobotSourceConfig(api_key="ur123-key"))++ @parameterized.expand(+ [+ ("tags_next_cursor_id", "tags", "/v3/tags", {"nextCursorId": 7}, {"nextCursorId": None}, "200"),+ (+ "monitor_groups_relative_next_link",+ "monitor_groups",+ "/v3/monitor-groups",+ {"nextLink": "/v3/monitor-groups?limit=200&cursor=7"},+ {"nextLink": None},+ "200",+ ),+ (+ "incidents_absolute_next_link",+ "incidents",+ "/v3/incidents",+ {"nextLink": "https://api.uptimerobot.com/v3/incidents?cursor=7"},+ {"nextLink": None},+ None,+ ),+ # Only the cursor is read from nextLink, so the bearer token never follows a foreign host.+ (+ "foreign_host_next_link",+ "incidents",+ "/v3/incidents",+ {"nextLink": "https://attacker.example.com/v3/incidents?cursor=7"},+ {},+ None,+ ),+ ]+ )+ def test_walks_cursor_pages_to_the_last_page(+ self,+ _name: str,+ endpoint: str,+ path: str,+ first_page_next: dict,+ last_page_next: dict,+ expected_limit: str | None,+ ) -> None:+ result = self._driver().run(+ endpoint,+ [+ ScriptedResponse(json={"data": [{"id": 1}, {"id": 2}], **first_page_next}),+ ScriptedResponse(json={"data": [{"id": 3}], **last_page_next}),+ ],+ )++ assert result.raised is None+ assert [row["id"] for row in result.rows] == [1, 2, 3]+ assert result.paths == [path, path]+ assert {request.origin for request in result.requests} == {"https://api.uptimerobot.com"}+ assert result.params("cursor") == [None, "7"]+ assert result.params("limit") == [expected_limit, expected_limit]+ assert {request.headers["authorization"] for request in result.requests} == {"Bearer ur123-key"}+ # The cursor of the next page is committed with the page it follows.+ assert result.committed_states == [UptimeRobotResumeConfig(cursor="7")]+ assert ("ur123-key",) in [options.get("redact_values") for options in result.session_options]++ def test_resumes_from_saved_cursor(self) -> None:+ result = self._driver().run(+ "tags",+ [ScriptedResponse(json={"data": [{"id": 9, "name": "prod"}], "nextCursorId": None})],+ resume_state=UptimeRobotResumeConfig(cursor="8"),+ )++ assert result.params("cursor") == ["8"]+ assert result.rows == [{"id": 9, "name": "prod"}]++ def test_cursor_that_does_not_move_ends_the_walk(self) -> None:+ result = self._driver().run(+ "tags",+ [+ ScriptedResponse(json={"data": [{"id": 1}], "nextCursorId": 5}),+ ScriptedResponse(json={"data": [{"id": 1}], "nextCursorId": 5}),+ ],+ )++ assert result.raised is None+ assert result.params("cursor") == [None, "5"]++ def test_empty_page_with_a_cursor_continues(self) -> None:+ result = self._driver().run(+ "incidents",+ [+ ScriptedResponse(json={"data": [], "nextLink": "https://api.uptimerobot.com/v3/incidents?cursor=4"}),+ ScriptedResponse(json={"data": [{"id": "4"}], "nextLink": None}),+ ],+ )++ assert result.params("cursor") == [None, "4"]+ assert result.rows == [{"id": "4"}]++ @parameterized.expand(+ [+ ("invalid_token", 401, {"message": "Invalid token.", "code": "003-005"}, UptimeRobotAuthError),+ ("scoped_key", 403, {"message": "Forbidden", "code": "000-003"}, requests.HTTPError),+ ]+ )+ def test_error_status_raises(self, _name: str, status: int, body: dict, expected: type[Exception]) -> None:+ result = self._driver().run("monitor_groups", [ScriptedResponse(status=status, json=body)])++ assert isinstance(result.raised, expected)+ if status == 401:+ assert str(result.raised).startswith(AUTH_ERROR_PREFIX)+ else:+ assert "403 Client Error: Forbidden for url: https://api.uptimerobot.com" in str(result.raised)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/uptimerobot.py b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/uptimerobot.pyindex 64e3758133dc..cfdaf2c451a6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/uptimerobot.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/uptimerobot/uptimerobot.py@@ -1,12 +1,15 @@import time-import dataclassesfrom collections.abc import Iteratorfrom datetime import UTC, date, datetimefrom typing import Any, Optional+from urllib.parse import parse_qs, urlparseimport requestsfrom structlog.types import FilteringBoundLogger-from tenacity import retry_if_exception_type, stop_after_attempt, wait_exponential_jitter+from tenacity import RetryCallState, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter+from urllib3.util.retry import Retry++from posthog.dataclasses import frozenfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.http import (make_tracked_session,@@ -19,10 +22,15 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.uptimeroboRESPONSE_TIMES_INITIAL_LOOKBACK_DAYS,RESPONSE_TIMES_WINDOW_DAYS,UPTIMEROBOT_ENDPOINTS,+ V3_PAGE_LIMIT,UptimeRobotEndpointConfig,)UPTIMEROBOT_BASE_URL = "https://api.uptimerobot.com/v2"+UPTIMEROBOT_V3_BASE_URL = "https://api.uptimerobot.com/v3"++# Cap on a server-requested v3 wait. Rate limits are per minute, so one window always fits.+MAX_RETRY_AFTER_SECONDS = 60# Stable prefix for credential failures — matched by `get_non_retryable_errors` on the source class.AUTH_ERROR_PREFIX = "UptimeRobot API key was rejected"@@ -62,7 +70,9 @@ def _scrub_alert_contact(row: dict[str, Any]) -> dict[str, Any]:class UptimeRobotRetryableError(Exception):- pass+ def __init__(self, message: str, retry_after: float | None = None) -> None:+ super().__init__(message)+ self.retry_after = retry_afterclass UptimeRobotAuthError(Exception):@@ -73,12 +83,14 @@ class UptimeRobotAPIError(Exception):pass+@frozenclass UptimeRobotResumeConfig:# Next 0-indexed row offset to fetch within the current listing.offset: int = 0# response_times only: Unix start of the 7-day window being fetched. None for other endpoints.window_start: int | None = None+ # v3 endpoints only: cursor of the next page to fetch.+ cursor: str | None = Nonedef _to_unix_timestamp(value: Any) -> int | None:@@ -150,6 +162,117 @@ def _post(session: requests.Session, method: str, data: dict[str, Any], logger:return payload+def _parse_retry_after(value: str | None) -> float | None:+ """Parse a delta-seconds `Retry-After` header. Anything else falls back to exponential backoff."""+ if not value:+ return None+ try:+ delay = float(value.strip())+ except ValueError:+ return None+ return delay if delay >= 0 else None+++_v3_backoff = wait_exponential_jitter(initial=1, max=30)+++def _v3_server_delay(retry_state: RetryCallState) -> float | None:+ exc = retry_state.outcome.exception() if retry_state.outcome is not None else None+ return exc.retry_after if isinstance(exc, UptimeRobotRetryableError) else None+++def _wait_v3(retry_state: RetryCallState) -> float:+ retry_after = _v3_server_delay(retry_state)+ if retry_after is not None:+ return min(retry_after, MAX_RETRY_AFTER_SECONDS)+ return _v3_backoff(retry_state)+++@retry_with_deadline(+ retry=retry_if_exception_type((UptimeRobotRetryableError, requests.ReadTimeout, requests.ConnectionError)),+ stop=stop_after_attempt(5),+ wait=_wait_v3,+ requested_wait=_v3_server_delay,+ reraise=True,+)+def _get_v3(+ session: requests.Session, path: str, params: dict[str, Any], logger: FilteringBoundLogger+) -> dict[str, Any]:+ """Call a v3 REST endpoint. v3 signals errors with real HTTP statuses, unlike v2."""+ response = session.get(f"{UPTIMEROBOT_V3_BASE_URL}{path}", params=params, timeout=60)++ if response.status_code == 429 or response.status_code >= 500:+ retry_after = _parse_retry_after(response.headers.get("Retry-After")) if response.status_code == 429 else None+ raise UptimeRobotRetryableError(+ f"UptimeRobot API error (retryable): status={response.status_code}, method={path}",+ retry_after=retry_after,+ )++ if response.status_code == 401:+ raise UptimeRobotAuthError(f"{AUTH_ERROR_PREFIX}: status=401, method={path}")++ if not response.ok:+ logger.error(f"UptimeRobot API error: status={response.status_code}, body={response.text}, method={path}")+ response.raise_for_status()++ return response.json()+++def _v3_next_cursor(payload: dict[str, Any]) -> str | None:+ """Return the cursor of the next v3 page, or None on the last page.++ /tags returns `nextCursorId`; the other list endpoints return a `nextLink` URL. Only the cursor is+ read from `nextLink`, so the bearer token is never sent to a host taken from a response body.+ """+ next_cursor_id = payload.get("nextCursorId")+ if next_cursor_id is not None:+ return str(next_cursor_id)++ next_link = payload.get("nextLink")+ if not next_link:+ return None+ cursors = parse_qs(urlparse(str(next_link)).query).get("cursor")+ return cursors[0] if cursors else None+++def _get_v3_rows(+ api_key: str,+ config: UptimeRobotEndpointConfig,+ logger: FilteringBoundLogger,+ resumable_source_manager: ResumableSourceManager[UptimeRobotResumeConfig],+ resume: UptimeRobotResumeConfig | None,+) -> Iterator[list[dict[str, Any]]]:+ # _get_v3 owns the retries, so the adapter retries are off to keep them from compounding.+ session = make_tracked_session(+ headers={"Authorization": f"Bearer {api_key}"}, redact_values=(api_key,), retry=Retry(total=0)+ )++ cursor = resume.cursor if resume is not None else None+ if cursor:+ logger.debug(f"UptimeRobot: resuming {config.name} from cursor {cursor}")++ while True:+ params: dict[str, Any] = {"limit": V3_PAGE_LIMIT} if config.v3_accepts_limit else {}+ if cursor:+ params["cursor"] = cursor+ payload = _get_v3(session, config.method, params, logger)+ rows = payload.get(config.response_key) or []+ next_cursor = _v3_next_cursor(payload)+ # A cursor that does not move would fetch the same page forever.+ if next_cursor == cursor:+ next_cursor = None++ if next_cursor is not None:+ resumable_source_manager.save_state(UptimeRobotResumeConfig(cursor=next_cursor))+ if rows:+ yield rows+ if next_cursor is None:+ break+ if not rows:+ resumable_source_manager.safe_point()+ cursor = next_cursor++def _form_data(api_key: str, config: UptimeRobotEndpointConfig, offset: int) -> dict[str, Any]:return {"api_key": api_key,@@ -326,7 +449,9 @@ def get_rows(else None)- if config.monitor_list_key == "response_times":+ if config.api_version == "v3":+ yield from _get_v3_rows(api_key, config, logger, resumable_source_manager, resume)+ elif config.monitor_list_key == "response_times":yield from _get_response_time_rows(session, api_key, config, logger, resumable_source_manager, resume, last_value_ts)