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(signals): pass the origin product as a plain string to the run cost read (#95069)

posthog[bot]de0227d21998
diff --git a/products/signals/backend/scout_harness/run_costs.py b/products/signals/backend/scout_harness/run_costs.py
index 69db17d408d7..4b6d3b8f0e5f 100644
--- a/products/signals/backend/scout_harness/run_costs.py
+++ b/products/signals/backend/scout_harness/run_costs.py
@@ -142,7 +142,7 @@ def _cache_key(*, team_id: int, task_run_id: str) -> str:
def _query_pending_costs(*, team_id: int, pending: list[_RunToPrice]) -> dict[str, Decimal | None]:
by_task_run_id = get_local_task_run_token_costs(
team_id=team_id,
- origin_product=tasks_facade.TaskOriginProduct.SIGNALS_SCOUT,
+ origin_product=tasks_facade.TaskOriginProduct.SIGNALS_SCOUT.value,
task_run_ids=[UUID(run.task_run_id) for run in pending],
generated_after=min(run.created_at for run in pending) - RUN_COST_LOOKBACK_MARGIN,
product=Product.SIGNALS,
diff --git a/products/signals/backend/test/test_scout_harness.py b/products/signals/backend/test/test_scout_harness.py
index d3a158a8ca6f..55b3f4e5f54a 100644
--- a/products/signals/backend/test/test_scout_harness.py
+++ b/products/signals/backend/test/test_scout_harness.py
@@ -2676,6 +2676,9 @@ class TestScoutRunTokenCosts(BaseTest):
query.assert_called_once()
called = query.call_args.kwargs
assert called["origin_product"] == "signals_scout"
+ # The HogQL escaper dispatches on the exact class, so a `TextChoices` member in the constant
+ # raises before the query runs. Equality alone does not catch that.
+ assert type(called["origin_product"]) is str
assert called["task_run_ids"] == [run.task_run_id]
# The window has to open before the run did, or the sum finds none of its generations.
assert called["generated_after"] < run.created_at