From 782c7519597ba8570b2431a8ebc3f25d74f8d89f Mon Sep 17 00:00:00 2001 From: Chris Busillo Date: Thu, 28 May 2026 15:41:31 -0400 Subject: [PATCH] Classify existing preview fetch outages --- .../workflows/verireel_preview_driver.py | 11 +++-- tests/test_verireel_preview_driver.py | 42 +++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/control_plane/workflows/verireel_preview_driver.py b/control_plane/workflows/verireel_preview_driver.py index 954228dd..2df4336e 100644 --- a/control_plane/workflows/verireel_preview_driver.py +++ b/control_plane/workflows/verireel_preview_driver.py @@ -1213,9 +1213,14 @@ def execute_verireel_preview_refresh( existing_snapshot = None if existing_application is not None: application_id = str(existing_application.get("applicationId") or "").strip() - existing_snapshot = _fetch_application( - host=host, token=token, application_id=application_id - ) + try: + existing_snapshot = _fetch_application( + host=host, token=token, application_id=application_id + ) + except click.ClickException as exc: + if _is_dokploy_provider_failure(exc): + raise VeriReelPreviewRefreshTransportError(str(exc)) from exc + raise VeriReelPreviewRefreshConfigError(str(exc)) from exc existing_database = _resolve_existing_preview_database(existing_snapshot) existing_env_map = control_plane_dokploy.parse_dokploy_env_text( str((existing_snapshot or {}).get("env") or "") diff --git a/tests/test_verireel_preview_driver.py b/tests/test_verireel_preview_driver.py index 5fe9a830..edcd2c22 100644 --- a/tests/test_verireel_preview_driver.py +++ b/tests/test_verireel_preview_driver.py @@ -399,6 +399,48 @@ def test_preview_refresh_maps_template_payload_fetch_failure_to_transport(self) record_store=None, ) + def test_preview_refresh_maps_existing_preview_fetch_failure_to_transport( + self, + ) -> None: + with ( + TemporaryDirectory() as temporary_directory_name, + patch( + "control_plane.workflows.verireel_preview_driver.control_plane_dokploy.read_dokploy_config", + return_value=("https://dokploy.example", "token"), + ), + patch( + "control_plane.workflows.verireel_preview_driver._template_application_payload", + return_value=( + _template_target(), + { + "applicationId": "app-template", + "env": "DATABASE_URL=postgresql://template:template-pass@db.example/verireel_testing\n", + }, + ), + ), + patch( + "control_plane.workflows.verireel_preview_driver._find_application_by_name", + return_value={"applicationId": "app-preview"}, + ), + patch( + "control_plane.workflows.verireel_preview_driver._fetch_application", + side_effect=click.ClickException( + "Dokploy API GET /api/application.one request failed: timed out" + ), + ), + patch( + "control_plane.workflows.verireel_preview_driver._run_application_command" + ) as run_command, + ): + with self.assertRaises(VeriReelPreviewRefreshTransportError): + execute_verireel_preview_refresh( + control_plane_root=Path(temporary_directory_name), + request=_refresh_request(), + record_store=None, + ) + + run_command.assert_not_called() + def test_preview_refresh_generates_preview_local_runtime_secrets(self) -> None: captured_env: dict[str, str] = {} template_master_key = base64.b64encode(b"template-master-key").decode("ascii")