From 82a6ae81bdf3259ebae90b8e00e22189f7f21a18 Mon Sep 17 00:00:00 2001 From: amszuidas <254873068+amszuidas@users.noreply.github.com> Date: Fri, 23 Jan 2026 17:01:38 +0800 Subject: [PATCH 1/3] fix: robust environment variable resolution in config --- backend/src/config/app_config.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/backend/src/config/app_config.py b/backend/src/config/app_config.py index f99dbbf..5178fe8 100644 --- a/backend/src/config/app_config.py +++ b/backend/src/config/app_config.py @@ -1,6 +1,6 @@ import os from pathlib import Path -from typing import Self +from typing import Any, Self import yaml from dotenv import load_dotenv @@ -90,7 +90,7 @@ class AppConfig(BaseModel): return result @classmethod - def resolve_env_variables(cls, config: dict) -> dict: + def resolve_env_variables(cls, config: Any) -> Any: """Recursively resolve environment variables in the config. Environment variables are resolved using the `os.getenv` function. Example: $OPENAI_API_KEY @@ -101,18 +101,14 @@ class AppConfig(BaseModel): Returns: The config with environment variables resolved. """ - for key, value in config.items(): - if isinstance(value, str): - if value.startswith("$"): - env_value = os.getenv(value[1:], None) - if env_value is not None: - config[key] = env_value - else: - config[key] = value - elif isinstance(value, dict): - config[key] = cls.resolve_env_variables(value) - elif isinstance(value, list): - config[key] = [cls.resolve_env_variables(item) for item in value] + if isinstance(config, str): + if config.startswith("$"): + return os.getenv(config[1:], config) + return config + elif isinstance(config, dict): + return {k: cls.resolve_env_variables(v) for k, v in config.items()} + elif isinstance(config, list): + return [cls.resolve_env_variables(item) for item in config] return config def get_model_config(self, name: str) -> ModelConfig | None: From eb802361e1af2430ba825bb4deb4b2f05dfa3918 Mon Sep 17 00:00:00 2001 From: amszuidas <254873068+amszuidas@users.noreply.github.com> Date: Fri, 23 Jan 2026 18:29:20 +0800 Subject: [PATCH 2/3] fix: correct spelling --- backend/src/sandbox/sandbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/sandbox/sandbox.py b/backend/src/sandbox/sandbox.py index 6255b4b..93ae2f6 100644 --- a/backend/src/sandbox/sandbox.py +++ b/backend/src/sandbox/sandbox.py @@ -27,7 +27,7 @@ class Sandbox(ABC): @abstractmethod def read_file(self, path: str) -> str: - """Read tge content of a file. + """Read the content of a file. Args: path: The absolute path of the file to read. From 3972485fe03cbbcdfc6b86049299712ac2e5fe06 Mon Sep 17 00:00:00 2001 From: amszuidas <254873068+amszuidas@users.noreply.github.com> Date: Fri, 23 Jan 2026 21:51:48 +0800 Subject: [PATCH 3/3] fix: use return value of resolve_env_variables in config loading --- backend/src/config/app_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/app_config.py b/backend/src/config/app_config.py index 5178fe8..f6ec1e4 100644 --- a/backend/src/config/app_config.py +++ b/backend/src/config/app_config.py @@ -72,7 +72,7 @@ class AppConfig(BaseModel): resolved_path = cls.resolve_config_path(config_path) with open(resolved_path) as f: config_data = yaml.safe_load(f) - cls.resolve_env_variables(config_data) + config_data = cls.resolve_env_variables(config_data) # Load title config if present if "title" in config_data: