: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(experiments): protect recalculation results and cancellation cleanup (#100056)
Andersb60387a13ff6
diff --git a/docs/internal/experiment-metric-recalculation.md b/docs/internal/experiment-metric-recalculation.mdnew file mode 100644index 000000000000..f250b4b00cd8--- /dev/null+++ b/docs/internal/experiment-metric-recalculation.md@@ -0,0 +1,27 @@+# Experiment metric recalculation cancellation++Experiment recalculations share result rows keyed by `(experiment, metric_uuid, query_to)`.+Stopped experiments reuse their fixed end date, so an abandoned run and its replacement can write the same row.++Result persistence locks the experiment and then the recalculation row in one transaction.+The status check and result upsert share that transaction, so a terminal transition either follows the old write or prevents it.+Missing, completed, and failed recalculations cannot write results.+The lock order matches `request_recalculation` and avoids a deadlock between supersession and the experiment foreign-key check on a new result.+ClickHouse queries and statistics run outside these locks.++The activity shields its synchronous calculation because canceling an asyncio task cannot stop a running worker thread.+After local activity cancellation, it waits for the calculation with a cleanup deadline of `METRIC_CALC_ACTIVITY_TIMEOUT_SECONDS` from the first cancellation.+Repeated cancellation does not restart or interrupt that wait.+The activity propagates the original cancellation even if the calculation fails during cleanup.++This cleanup preserves the worker's activity slot while it waits; it does not stop the query or immediately release its memory.+The deadline bounds cleanup, not the underlying thread's lifetime.+Precomputation, executor queuing, statistics, and database waits can extend beyond the final ClickHouse query's execution limit.+A calculation can therefore continue after the cleanup deadline expires.++The workflow does not configure activity heartbeats.+Temporal requires heartbeats and a heartbeat timeout to deliver workflow cancellation to a running activity, so supersession does not promptly interrupt the calculation.+Prompt cancellation would require heartbeat delivery plus cooperative cancellation through precomputation and the query runner, with cleanup for any active ClickHouse query.+Result-write protection must remain independent of cancellation delivery.++See the [workflow architecture](../../products/experiments/backend/temporal/ARCHITECTURE.md) and [Temporal's cancellation contract](https://github.com/temporalio/sdk-python#heartbeating-and-cancellation).diff --git a/products/experiments/backend/temporal/ARCHITECTURE.md b/products/experiments/backend/temporal/ARCHITECTURE.mdindex d1df2ef2f452..f9616a164fcc 100644--- a/products/experiments/backend/temporal/ARCHITECTURE.md+++ b/products/experiments/backend/temporal/ARCHITECTURE.md@@ -150,7 +150,10 @@ The split is intentional: Grafana tells you about the worker process, PostHog te- **In-query execution guard.** The calc activity sets ClickHouse `max_execution_time=270s` (`METRIC_CALC_MAX_EXECUTION_TIME_SECONDS`), deliberately below the 300s activity timeout. A slow query then fails inside the activity with a typed ClickHouse timeout error, so the FAILED result row and the terminal event still get written, instead of Temporal killing the attempt from the outside and losing all of that.-- **5-minute per-attempt budget.** `start_to_close_timeout=timedelta(minutes=5)` on the calc activity is the real per-attempt ceiling. We deliberately don't set a heartbeat timeout: the activity has no progress hooks inside the ClickHouse query, so the heartbeat couldn't fire mid-query anyway.+- **5-minute per-attempt budget.** `start_to_close_timeout=timedelta(minutes=5)` limits the attempt in Temporal, but cannot stop the synchronous calculation thread.+ Local activity cancellation waits for that thread with a bounded cleanup deadline.+ The activity has no heartbeats, so workflow cancellation does not promptly reach it.+ See [cancellation and result-write protection](../../../../docs/internal/experiment-metric-recalculation.md) for the locking contract and cleanup limits.- **Calc queries run on the online ClickHouse cluster.** The calc activity builds its `ExperimentQueryRunner` with `workload=Workload.ONLINE`, so the queries hit the same replicas that serve interactive product traffic rather than the offline cluster that heavy background jobs use.This is a deliberate trade-off against the offline default that most background scans take. The offline replicas can trail ingestion, disable hedged requests (higher and more variable latency, higher failure rate), and share one global concurrency limit across every product. A recalc is a user-initiated snapshot the person is waiting on, so it wants the freshest data and the most reliable, lowest-latency path, which is the online cluster. The cost is that recalc scans now compete with live user queries instead of being isolated from them; the worker's activity-slot cap and the per-org ClickHouse app-query limiter are what keep that load bounded.diff --git a/products/experiments/backend/temporal/recalculation_activities.py b/products/experiments/backend/temporal/recalculation_activities.pyindex 977b1dd51843..4e59842e6cb3 100644--- a/products/experiments/backend/temporal/recalculation_activities.py+++ b/products/experiments/backend/temporal/recalculation_activities.py@@ -5,10 +5,14 @@ These are thin ``@temporalio.activity.defn`` wrappers; the DB-touching implementand lets the logic be unit-tested without the activity decorator."""+import asyncio++import structlogimport temporalio.activityfrom products.experiments.backend.temporal.models import (MAX_METRIC_ATTEMPTS,+ METRIC_CALC_ACTIVITY_TIMEOUT_SECONDS,ExperimentMetricToRecalculate,MetricRecalculationResult,RecalculationProgressUpdate,@@ -19,6 +23,8 @@ from products.experiments.backend.temporal.recalculation_logic import (_update_recalculation_progress_sync,)+logger = structlog.get_logger(__name__)+@temporalio.activity.defnasync def discover_experiment_metrics(recalculation_id: str) -> list[ExperimentMetricToRecalculate]:@@ -57,6 +63,29 @@ async def calculate_experiment_metric_for_recalculation("""attempt = temporalio.activity.info().attemptis_final_attempt = attempt >= MAX_METRIC_ATTEMPTS- return await _calculate_experiment_metric_for_recalculation_sync(- experiment_id, metric_uuid, recalculation_id, query_to, metric_type, is_final_attempt, attempt+ task = asyncio.ensure_future(+ _calculate_experiment_metric_for_recalculation_sync(+ experiment_id, metric_uuid, recalculation_id, query_to, metric_type, is_final_attempt, attempt+ ))+ try:+ return await asyncio.shield(task)+ except asyncio.CancelledError:+ # Keep the worker slot while the uncancellable thread finishes, but bound shutdown cleanup.+ drain = asyncio.create_task(asyncio.wait_for(asyncio.shield(task), METRIC_CALC_ACTIVITY_TIMEOUT_SECONDS))+ while True:+ try:+ await asyncio.shield(drain)+ break+ except asyncio.CancelledError:+ if drain.cancelled():+ break+ except Exception:+ logger.warning(+ "experiment_metric_recalculation_drain_after_cancel_failed",+ metric_uuid=metric_uuid,+ recalculation_id=recalculation_id,+ exc_info=True,+ )+ break+ raisediff --git a/products/experiments/backend/temporal/recalculation_logic.py b/products/experiments/backend/temporal/recalculation_logic.pyindex 4c1e1b87bbf3..8788ec861596 100644--- a/products/experiments/backend/temporal/recalculation_logic.py+++ b/products/experiments/backend/temporal/recalculation_logic.py@@ -63,6 +63,10 @@ logger = structlog.get_logger(__name__)# Cap stored/returned error messages so a pathological traceback can't bloat the Temporal payload (~2 MiB cap)._MAX_ERROR_MESSAGE_LENGTH = 2000+_TERMINAL_RECALC_STATUSES = frozenset(+ {ExperimentMetricsRecalculation.Status.COMPLETED, ExperimentMetricsRecalculation.Status.FAILED}+)+# ---------------------------------------------------------------------------# Discovery@@ -484,6 +488,7 @@ def _clear_retry(recalculation_id: str, metric_uuid: str) -> None:def _store_result(*,+ recalculation_id: str,experiment_id: int,metric_uuid: str,recalc_fp: str,@@ -494,23 +499,41 @@ def _store_result(error_message: str | None,query_id: str | None = None,) -> None:- # Upsert on the true unique key (experiment, metric_uuid, query_to); fingerprint goes in defaults so a row- # already occupying that key under a different fingerprint is updated in place, not inserted as a colliding- # duplicate. This heals rows written under the old per-run fingerprint scheme.- ExperimentMetricResult.objects.update_or_create(- experiment_id=experiment_id,- metric_uuid=metric_uuid,- query_to=query_to,- defaults={- "fingerprint": recalc_fp,- "query_from": query_from,- "status": status,- "result": result,- "query_id": query_id,- "completed_at": timezone.now() if status == ExperimentMetricResult.Status.COMPLETED else None,- "error_message": error_message,- },- )+ with transaction.atomic():+ # Match request_recalculation's lock order; result inserts also take an experiment FK lock.+ Experiment.objects.select_for_update(no_key=True).filter(id=experiment_id).exists()+ current_status = (+ ExperimentMetricsRecalculation.objects.select_for_update()+ .filter(id=recalculation_id, experiment_id=experiment_id)+ .values_list("status", flat=True)+ .first()+ )+ if current_status is None or current_status in _TERMINAL_RECALC_STATUSES:+ logger.warning(+ "Skipping experiment metric result write for a terminal or missing recalculation",+ recalculation_id=recalculation_id,+ metric_uuid=metric_uuid,+ recalculation_status=current_status,+ )+ return++ # Upsert on the true unique key (experiment, metric_uuid, query_to); fingerprint goes in defaults so a row+ # already occupying that key under a different fingerprint is updated in place, not inserted as a colliding+ # duplicate. This heals rows written under the old per-run fingerprint scheme.+ ExperimentMetricResult.objects.update_or_create(+ experiment_id=experiment_id,+ metric_uuid=metric_uuid,+ query_to=query_to,+ defaults={+ "fingerprint": recalc_fp,+ "query_from": query_from,+ "status": status,+ "result": result,+ "query_id": query_id,+ "completed_at": timezone.now() if status == ExperimentMetricResult.Status.COMPLETED else None,+ "error_message": error_message,+ },+ )def _fail(recalculation_id: str, metric_uuid: str, step: str, message: str) -> MetricRecalculationResult:@@ -685,6 +708,36 @@ def _calculate_experiment_metric_for_recalculation_sync(client_query_id = f"experiment_metric_recalc_{recalculation_id}_{metric_uuid}"calc_started_at = time.perf_counter()+ query_from = experiment.start_date++ def record_terminal_error(message: str, error_type: str) -> None:+ _store_result(+ recalculation_id=recalculation_id,+ experiment_id=experiment_id,+ metric_uuid=metric_uuid,+ recalc_fp=recalc_fp,+ query_from=query_from,+ query_to=query_to_dt,+ status=ExperimentMetricResult.Status.FAILED,+ result=None,+ error_message=message,+ query_id=client_query_id,+ )+ _record_failure(recalculation_id, metric_uuid, "calculation", message)+ _capture_experiment_metric_event(+ experiment,+ metric_uuid,+ metric_type,+ metric_dict,+ "experiment metric error",+ {+ "duration_ms": round((time.perf_counter() - calc_started_at) * 1000),+ "error_type": error_type,+ "error_message": message,+ },+ trigger=state.trigger,+ )+try:runner = ExperimentQueryRunner(query=ExperimentQuery(experiment_id=experiment_id, metric=build_metric(metric_dict)),@@ -716,6 +769,7 @@ def _calculate_experiment_metric_for_recalculation_sync(result_dict = sanitize_non_finite(result.model_dump(mode="json"))_store_result(+ recalculation_id=recalculation_id,experiment_id=experiment_id,metric_uuid=metric_uuid,recalc_fp=recalc_fp,@@ -742,6 +796,7 @@ def _calculate_experiment_metric_for_recalculation_sync(# Expected "not enough data" style failures — warn, no exception capture.message = str(e)[:_MAX_ERROR_MESSAGE_LENGTH]_store_result(+ recalculation_id=recalculation_id,experiment_id=experiment_id,metric_uuid=metric_uuid,recalc_fp=recalc_fp,@@ -776,31 +831,7 @@ def _calculate_experiment_metric_for_recalculation_sync(except (ConcurrencyLimitExceeded, ClickHouseAtCapacity) as e:message = str(e)[:_MAX_ERROR_MESSAGE_LENGTH]if is_final_attempt:- _store_result(- experiment_id=experiment_id,- metric_uuid=metric_uuid,- recalc_fp=recalc_fp,- query_from=experiment.start_date,- query_to=query_to_dt,- status=ExperimentMetricResult.Status.FAILED,- result=None,- error_message=message,- query_id=client_query_id,- )- _record_failure(recalculation_id, metric_uuid, "calculation", message)- _capture_experiment_metric_event(- experiment,- metric_uuid,- metric_type,- metric_dict,- "experiment metric error",- {- "duration_ms": round((time.perf_counter() - calc_started_at) * 1000),- "error_type": classify_experiment_query_error(e),- "error_message": message,- },- trigger=state.trigger,- )+ record_terminal_error(message, classify_experiment_query_error(e))logger.warning("Experiment metric recalculation deferred by ClickHouse backpressure",experiment_id=experiment_id,@@ -860,31 +891,7 @@ def _calculate_experiment_metric_for_recalculation_sync(},)if is_final_attempt or is_permanent:- _store_result(- experiment_id=experiment_id,- metric_uuid=metric_uuid,- recalc_fp=recalc_fp,- query_from=experiment.start_date,- query_to=query_to_dt,- status=ExperimentMetricResult.Status.FAILED,- result=None,- error_message=message,- query_id=client_query_id,- )- _record_failure(recalculation_id, metric_uuid, "calculation", message)- _capture_experiment_metric_event(- experiment,- metric_uuid,- metric_type,- metric_dict,- "experiment metric error",- {- "duration_ms": round((time.perf_counter() - calc_started_at) * 1000),- "error_type": error_type,- "error_message": message,- },- trigger=state.trigger,- )+ record_terminal_error(message, error_type)logger.exception("Experiment metric recalculation failed",experiment_id=experiment_id,diff --git a/products/experiments/backend/temporal/test_recalculation_activities.py b/products/experiments/backend/temporal/test_recalculation_activities.pyindex eeffbf85559d..634dbaa78251 100644--- a/products/experiments/backend/temporal/test_recalculation_activities.py+++ b/products/experiments/backend/temporal/test_recalculation_activities.py@@ -1,5 +1,7 @@+import asynciofrom contextlib import contextmanagerfrom datetime import datetime, timedelta+from types import SimpleNamespaceimport pytestimport time_machine@@ -28,9 +30,11 @@ from products.experiments.backend.models.experiment import (from products.experiments.backend.temporal.models import (CONCURRENCY_LIMIT_RETRY_DELAY_SECONDS,MAX_METRIC_ATTEMPTS,+ MetricRecalculationResult,RecalculationProgressUpdate,)from products.experiments.backend.temporal.recalc_fingerprint import compute_recalc_fingerprint+from products.experiments.backend.temporal.recalculation_activities import calculate_experiment_metric_for_recalculationfrom products.experiments.backend.temporal.recalculation_logic import (_calculate_experiment_metric_for_recalculation_sync,_discover_experiment_metrics_sync,@@ -1049,6 +1053,7 @@ class TestCalculateActivity(BaseTest):# scheme, or the timeseries workflow). _store_result must update that row in place, not insert a second# one and crash with IntegrityError. This is what unsticks experiments already collided in production.exp = self._experiment(flag_key="store-upsert-key", metrics=[_mean_metric("m1")])+ recalc = self._recalc(exp, metric_uuids=["m1"])query_to = datetime.fromisoformat(_QUERY_TO)ExperimentMetricResult.objects.create(experiment=exp,@@ -1061,6 +1066,7 @@ class TestCalculateActivity(BaseTest):)_store_result(+ recalculation_id=str(recalc.id),experiment_id=exp.id,metric_uuid="m1",recalc_fp="new-deterministic-fingerprint",@@ -1077,6 +1083,48 @@ class TestCalculateActivity(BaseTest):assert row.fingerprint == "new-deterministic-fingerprint"assert row.result == {"fresh": True}+ @parameterized.expand(+ [+ (ExperimentMetricsRecalculation.Status.FAILED,),+ (ExperimentMetricsRecalculation.Status.COMPLETED,),+ (None,),+ ]+ )+ def test_store_result_skips_a_terminal_or_missing_recalculation(self, status: str | None) -> None:+ exp = self._experiment(flag_key="store-superseded", metrics=[_mean_metric("m1")])+ recalc = self._recalc(exp, metric_uuids=["m1"])+ if status is None:+ ExperimentMetricsRecalculation.objects.filter(id=recalc.id).delete()+ else:+ ExperimentMetricsRecalculation.objects.filter(id=recalc.id).update(status=status)+ query_to = datetime.fromisoformat(_QUERY_TO)+ ExperimentMetricResult.objects.create(+ experiment=exp,+ metric_uuid="m1",+ fingerprint="fingerprint-from-the-superseding-run",+ query_from=query_to,+ query_to=query_to,+ status=ExperimentMetricResult.Status.COMPLETED,+ result={"fresh": True},+ )++ _store_result(+ recalculation_id=str(recalc.id),+ experiment_id=exp.id,+ metric_uuid="m1",+ recalc_fp="fingerprint-from-the-orphaned-run",+ query_from=query_to,+ query_to=query_to,+ status=ExperimentMetricResult.Status.FAILED,+ result=None,+ error_message="the orphan's late failure",+ )++ row = ExperimentMetricResult.objects.get(experiment=exp, metric_uuid="m1", query_to=query_to)+ assert row.status == ExperimentMetricResult.Status.COMPLETED+ assert row.result == {"fresh": True}+ assert row.error_message is None+@parameterized.expand([# (name, metric_uuid, metrics_on_experiment, run_with_mocked_failure, expected_result_rows)@@ -1222,6 +1270,78 @@ class TestMissingRecalcRow:assert exc_info.value.non_retryable is True+class TestCalculateActivityCancellation:+ @pytest.mark.parametrize("cancellations", [1, 2])+ @pytest.mark.parametrize("body_fails", [False, True])+ async def test_cancellation_drains_the_body_before_propagating(self, cancellations: int, body_fails: bool) -> None:+ started = asyncio.Event()+ release = asyncio.Event()+ body_finished = False++ async def _slow_body(*args: object, **kwargs: object) -> MetricRecalculationResult:+ nonlocal body_finished+ started.set()+ await release.wait()+ body_finished = True+ if body_fails:+ raise RuntimeError("calculation failed during cleanup")+ return MetricRecalculationResult(metric_uuid="m1", success=True)++ with (+ patch(+ "products.experiments.backend.temporal.recalculation_activities._calculate_experiment_metric_for_recalculation_sync",+ _slow_body,+ ),+ patch("temporalio.activity.info", return_value=SimpleNamespace(attempt=1)),+ ):+ task = asyncio.create_task(calculate_experiment_metric_for_recalculation(1, "m1", "r1", _QUERY_TO))+ await started.wait()+ try:+ for cancellation in range(cancellations):+ task.cancel(f"cancel-{cancellation}")+ await asyncio.sleep(0)+ assert not task.done()+ finally:+ release.set()++ with pytest.raises(asyncio.CancelledError, match="cancel-0"):+ await task++ assert body_finished is True++ async def test_cancellation_drain_has_a_deadline(self) -> None:+ started = asyncio.Event()+ release = asyncio.Event()+ body_finished = asyncio.Event()++ async def _slow_body(*args: object, **kwargs: object) -> MetricRecalculationResult:+ started.set()+ await release.wait()+ body_finished.set()+ return MetricRecalculationResult(metric_uuid="m1", success=True)++ with (+ patch(+ "products.experiments.backend.temporal.recalculation_activities._calculate_experiment_metric_for_recalculation_sync",+ _slow_body,+ ),+ patch("temporalio.activity.info", return_value=SimpleNamespace(attempt=1)),+ patch(+ "products.experiments.backend.temporal.recalculation_activities.METRIC_CALC_ACTIVITY_TIMEOUT_SECONDS", 0+ ),+ ):+ task = asyncio.create_task(calculate_experiment_metric_for_recalculation(1, "m1", "r1", _QUERY_TO))+ await started.wait()+ try:+ task.cancel("original cancellation")+ with pytest.raises(asyncio.CancelledError, match="original cancellation"):+ await asyncio.wait_for(task, timeout=5)+ assert not body_finished.is_set()+ finally:+ release.set()+ await asyncio.wait_for(body_finished.wait(), timeout=5)++@contextmanagerdef _record_captures():"""Patch the global posthoganalytics client so the analytics tests can assert the exact eventdiff --git a/products/experiments/backend/temporal/test_recalculation_concurrency.py b/products/experiments/backend/temporal/test_recalculation_concurrency.pynew file mode 100644index 000000000000..f39e5f3b3e79--- /dev/null+++ b/products/experiments/backend/temporal/test_recalculation_concurrency.py@@ -0,0 +1,108 @@+from concurrent.futures import ThreadPoolExecutor+from datetime import timedelta+from queue import Queue+from time import monotonic++import pytest+import time_machine+from unittest.mock import patch++from django.db import connection, connections, transaction+from django.utils import timezone++from posthog.models import Team, User+from posthog.models.scoping import team_scope++from products.experiments.backend.models.experiment import (+ Experiment,+ ExperimentMetricResult,+ ExperimentMetricsRecalculation,+)+from products.experiments.backend.recalculation import request_recalculation+from products.experiments.backend.temporal.recalculation_logic import _store_result+from products.feature_flags.backend.models.feature_flag import FeatureFlag++[email protected]_db(transaction=True)[email protected]("existing_result", [False, True])+@time_machine.travel("2026-09-01T12:00:00Z", tick=False)+def test_superseded_result_cannot_overwrite_a_replacement_during_commit(+ team: Team, user: User, existing_result: bool+) -> None:+ query_to = timezone.now()+ query_from = query_to - timedelta(days=2)+ experiment = Experiment.objects.create(+ team=team,+ name="Concurrent recalculation",+ feature_flag=FeatureFlag.objects.create(team=team, key="concurrent-recalculation"),+ start_date=query_from,+ end_date=query_to,+ )+ stale = ExperimentMetricsRecalculation.objects.for_team(team.id).create(+ team=team,+ experiment=experiment,+ status=ExperimentMetricsRecalculation.Status.IN_PROGRESS,+ started_at=query_to - timedelta(hours=2),+ query_to=query_to,+ )+ result_key = {"experiment_id": experiment.id, "metric_uuid": "m1", "query_to": query_to}+ if existing_result:+ ExperimentMetricResult.objects.create(+ **result_key, fingerprint="previous", query_from=query_from, result={"previous": True}+ )++ worker_pid: Queue[int] = Queue()++ def store_stale_result() -> None:+ try:+ with team_scope(team.id, canonical=True), connection.cursor() as cursor:+ cursor.execute("SELECT pg_backend_pid()")+ worker_pid.put(cursor.fetchone()[0])+ _store_result(+ recalculation_id=str(stale.id),+ experiment_id=experiment.id,+ metric_uuid="m1",+ query_to=query_to,+ recalc_fp="stale",+ query_from=query_from,+ status=ExperimentMetricResult.Status.FAILED,+ result=None,+ error_message="abandoned calculation failed",+ )+ finally:+ connections.close_all()++ with (+ patch("products.experiments.backend.recalculation._cancel_superseded_workflows"),+ ThreadPoolExecutor(max_workers=1) as executor,+ ):+ with transaction.atomic():+ request_recalculation(experiment, user)+ ExperimentMetricResult.objects.update_or_create(+ experiment_id=experiment.id,+ metric_uuid="m1",+ query_to=query_to,+ defaults={+ "fingerprint": "replacement",+ "query_from": query_from,+ "status": ExperimentMetricResult.Status.COMPLETED,+ "result": {"fresh": True},+ },+ )+ writer = executor.submit(store_stale_result)+ pid = worker_pid.get(timeout=5)+ deadline = monotonic() + 5+ with connection.cursor() as cursor:+ while True:+ cursor.execute("SELECT cardinality(pg_blocking_pids(%s)) > 0", [pid])+ if cursor.fetchone()[0]:+ break+ assert not writer.done(), "stale writer finished before the replacement committed"+ assert monotonic() < deadline, "stale writer did not reach the concurrent write"+ writer.result(timeout=5)++ result = ExperimentMetricResult.objects.get(**result_key)+ assert result.status == ExperimentMetricResult.Status.COMPLETED+ assert result.fingerprint == "replacement"+ assert result.result == {"fresh": True}+ assert result.error_message is None