Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
Feature/dummy fallback config for ssl error (#552)
Louis Choquel81c00cf19ce9
diff --git a/pipelex/system/pipelex_service/remote_config_fetcher.py b/pipelex/system/pipelex_service/remote_config_fetcher.pyindex ec93ebe08..eef69adb4 100644--- a/pipelex/system/pipelex_service/remote_config_fetcher.py+++ b/pipelex/system/pipelex_service/remote_config_fetcher.py@@ -7,7 +7,8 @@ from pipelex.system.pipelex_service.exceptions import (RemoteConfigValidationError,)from pipelex.system.pipelex_service.pipelex_details import PipelexDetails-from pipelex.system.pipelex_service.remote_config import RemoteConfig+from pipelex.system.pipelex_service.remote_config import PipelexPosthogConfig, RemoteConfig+from pipelex.system.runtime import runtime_managerfrom pipelex.tools.misc.terminal_utils import print_to_stderrfrom pipelex.tools.typing.pydantic_utils import format_pydantic_validation_error@@ -59,6 +60,23 @@ class RemoteConfigFetcher:return _fetch_with_retry(url)+ @classmethod+ def _make_dummy_remote_config(cls) -> RemoteConfig:+ """Create a default RemoteConfig for testing in offline environments.++ Returns:+ A minimal RemoteConfig with analytics disabled and empty model specs.+ """+ return RemoteConfig(+ posthog=PipelexPosthogConfig(+ project_api_key="",+ endpoint="https://dummy-endpoint.pipelex.com",+ is_geoip_enabled=False,+ is_debug_enabled=False,+ ),+ backend_model_specs={},+ )+@classmethoddef fetch_remote_config(cls) -> RemoteConfig:"""Fetch Pipelex Service remote configuration.@@ -70,6 +88,11 @@ class RemoteConfigFetcher:RemoteConfigFetchError: If the HTTP request fails or returns an error.RemoteConfigValidationError: If the JSON doesn't match expected schema."""+ # In Codex Cloud, return dummy config to avoid SSL issues with MITM proxy+ if runtime_manager.is_in_codex_cloud:+ print_to_stderr("Skipping remote config fetch in Codex Cloud, using dummy config instead")+ return cls._make_dummy_remote_config()+url = PipelexDetails.REMOTE_CONFIG_URLtry:diff --git a/pipelex/system/runtime.py b/pipelex/system/runtime.pyindex 98bb5d28f..bfec9bba1 100644--- a/pipelex/system/runtime.py+++ b/pipelex/system/runtime.py@@ -142,5 +142,9 @@ class RuntimeManager(BaseModel):case RunMode.CODEX_CLOUD_TEST:return True+ @property+ def is_in_codex_cloud(self) -> bool:+ return self.run_mode in {RunMode.CODEX_CLOUD, RunMode.CODEX_CLOUD_TEST}+runtime_manager = RuntimeManager()diff --git a/tests/unit/pipelex/tools/test_testing.py b/tests/unit/pipelex/tools/test_testing.pyindex 139b0a430..03ad95a11 100644--- a/tests/unit/pipelex/tools/test_testing.py+++ b/tests/unit/pipelex/tools/test_testing.py@@ -1,5 +1,5 @@-from pipelex.system.environment import is_env_var_set-from pipelex.system.runtime import RunMode, runtime_manager+from pipelex.system.environment import is_env_var_set, is_env_var_truthy+from pipelex.system.runtime import CODEX_CLOUD_ENV_VAR_KEY, RunMode, runtime_managerdef test_testing():@@ -9,6 +9,8 @@ def test_testing():case RunMode.UNIT_TEST:assert not is_env_var_set(key="GITHUB_ACTIONS")assert not is_env_var_set(key="CI")+ case RunMode.CODEX_CLOUD_TEST:+ assert is_env_var_truthy(key=CODEX_CLOUD_ENV_VAR_KEY)case _:msg = f"Invalid run mode: {runtime_manager.run_mode}"raise RuntimeError(msg)