From 9f940c4988b8a6ad46c7ef742952e3286cd66cef Mon Sep 17 00:00:00 2001 From: kfiramar <83420275+kfiramar@users.noreply.github.com> Date: Sun, 12 Jul 2026 19:55:07 +0300 Subject: [PATCH] fix(preview): provide generated secrets during import --- python/envctl_engine/pr_preview_controller.py | 9 ++++++--- tests/python/runtime/test_pr_preview_controller.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/python/envctl_engine/pr_preview_controller.py b/python/envctl_engine/pr_preview_controller.py index 3ee8574f..0c3b86a0 100644 --- a/python/envctl_engine/pr_preview_controller.py +++ b/python/envctl_engine/pr_preview_controller.py @@ -1967,8 +1967,12 @@ def start( started_at = utc_now() expires_at = label_added_at + timedelta(minutes=self.config.ttl_minutes) + repository_preview_env: dict[str, str] = {} + self.apply_repository_preview_env(repository_preview_env, pr_number=pr.number) def run_import() -> CommandResult: + import_env = self.envctl_command_env(keep_github_tokens=True) + import_env.update(repository_preview_env) return self.runner.run( [ self.config.envctl_bin, @@ -1981,7 +1985,7 @@ def run_import() -> CommandResult: ], cwd=self.config.control_repo, check=False, - env=self.envctl_command_env(keep_github_tokens=True), + env=import_env, ) import_result = run_import() @@ -2081,6 +2085,7 @@ def run_import() -> CommandResult: start_env = self.envctl_command_env() start_env.update(pr_preview_start_env_overrides()) + start_env.update(repository_preview_env) start_env.update(self.external_dependency_start_env(external_dependencies)) python_setup_error = "" try: @@ -2105,8 +2110,6 @@ def run_import() -> CommandResult: start_env["ENVCTL_FRONTEND_ENV__VITE_BACKEND_URL"] = public_urls["backend"] if public_urls.get("supabase"): start_env["ENVCTL_FRONTEND_ENV__VITE_SUPABASE_URL"] = public_urls["supabase"] - self.apply_repository_preview_env(start_env, pr_number=pr.number) - start_argv = [ self.config.envctl_bin, "start", diff --git a/tests/python/runtime/test_pr_preview_controller.py b/tests/python/runtime/test_pr_preview_controller.py index a9a6fdbf..df659496 100644 --- a/tests/python/runtime/test_pr_preview_controller.py +++ b/tests/python/runtime/test_pr_preview_controller.py @@ -972,6 +972,16 @@ def test_repository_envctl_config_drives_dynamic_public_service_and_secrets( assert len(generated) == 3 assert all(len(value) >= 48 for value in generated) + import_call = next(call for call in runner.calls if call["argv"][:2] == ["envctl", "import"]) + import_env = import_call["env"] + for name in ( + "PIPECAT_SERVICE_TOKEN", + "PIPECAT_WEBHOOK_SECRET", + "PIPECAT_STREAM_TOKEN_SECRET", + ): + key = f"ENVCTL_SOURCE_{name}" + assert import_env[key] == start_env[key] + state = instance.load_state(789) assert state is not None runtime = state.endpoints["additional_services"]["voice-runtime"]