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(data-imports): alias RunPod network volume billing startDate to time (#76452)

Tom Owersea01c9821231
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/runpod/runpod.py b/products/warehouse_sources/backend/temporal/data_imports/sources/runpod/runpod.py
index 5209578185e5..e8cc8a155a2e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/runpod/runpod.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/runpod/runpod.py
@@ -132,9 +132,19 @@ def _row_id(*parts: Any) -> str:
def _normalize_billing_record(record: dict[str, Any]) -> dict[str, Any]:
+ normalized = dict(record)
+ if "time" not in normalized and "startDate" in normalized:
+ # RunPod's network volume billing has been observed returning the bucket start under
+ # `startDate` rather than the `time` field documented for every other billing endpoint,
+ # so alias it here to keep the schema's declared "time" incremental field valid.
+ normalized["time"] = normalized.pop("startDate")
return {
- "id": _row_id(record.get("time"), record.get("podId"), record.get("endpointId"), record.get("gpuTypeId")),
- **record,
+ **normalized,
+ # Set last so a record that happens to carry its own "id" key can never override the
+ # synthesized surrogate id merge relies on for dedup.
+ "id": _row_id(
+ normalized.get("time"), normalized.get("podId"), normalized.get("endpointId"), normalized.get("gpuTypeId")
+ ),
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/runpod/tests/test_runpod.py b/products/warehouse_sources/backend/temporal/data_imports/sources/runpod/tests/test_runpod.py
index 3f0405433dc2..bdb5cb788055 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/runpod/tests/test_runpod.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/runpod/tests/test_runpod.py
@@ -12,6 +12,7 @@ from parameterized import parameterized
from products.warehouse_sources.backend.temporal.data_imports.sources.runpod import runpod
from products.warehouse_sources.backend.temporal.data_imports.sources.runpod.runpod import (
RunPodResumeConfig,
+ _normalize_billing_record,
_row_id,
get_rows,
validate_credentials,
@@ -74,6 +75,20 @@ class TestRowId:
assert _row_id(None, "x") != _row_id("x", None)
+class TestNormalizeBillingRecord:
+ def test_start_date_is_aliased_to_time_when_time_is_missing(self) -> None:
+ # RunPod's network volume billing endpoint has been observed returning `startDate` instead
+ # of the `time` field every other billing endpoint (and our declared incremental field)
+ # relies on, so without this alias `time` never lands in the yielded row.
+ record = _normalize_billing_record({"startDate": "2025-08-01T00:00:00Z", "amount": 1.5})
+ assert record["time"] == "2025-08-01T00:00:00Z"
+ assert "startDate" not in record
+
+ def test_time_is_left_untouched_when_already_present(self) -> None:
+ record = _normalize_billing_record({"time": "2025-08-01T00:00:00Z", "podId": "p1"})
+ assert record["time"] == "2025-08-01T00:00:00Z"
+
+
@freeze_time("2022-05-15T12:00:00Z")
class TestBillingWindows:
def test_full_refresh_walks_windows_from_launch_date(self) -> None: