From 794a8d2f201f439b83cafb61b5b9fe612e77ffc4 Mon Sep 17 00:00:00 2001 From: Ziiii <273036393+zixuanguo786-ctrl@users.noreply.github.com> Date: Mon, 6 Jul 2026 15:42:22 +0800 Subject: [PATCH] Make env-var default hints copyable When a required environment variable is missing, the loader should show the exact fallback syntax users can paste. The previous f-string escaped the example incorrectly, making the suggestion harder to follow. Constraint: Keep environment-variable resolution semantics unchanged. Rejected: Remove the suggestion | the actionable hint is useful when the variable is intentionally optional. Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep user-facing configuration errors copyable. Tested: uv run pytest tests/test_config/test_loader.py -q Tested: uv run ruff check src/conductor/config/loader.py tests/test_config/test_loader.py Not-tested: Full CLI validation suite. --- src/conductor/config/loader.py | 2 +- tests/test_config/test_loader.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conductor/config/loader.py b/src/conductor/config/loader.py index c304f4fc..6ecc7d02 100644 --- a/src/conductor/config/loader.py +++ b/src/conductor/config/loader.py @@ -60,7 +60,7 @@ def replace_env_var(match: re.Match) -> str: raise ConfigurationError( f"Required environment variable '{var_name}' is not set", suggestion=f"Set the environment variable '{var_name}' or provide a default " - f"value using the syntax: ${{{{{{var_name}}}}:-default_value}}", + "value using the syntax: " + "${" + var_name + ":-default_value}", ) # Perform substitution diff --git a/tests/test_config/test_loader.py b/tests/test_config/test_loader.py index 74130c95..810d8604 100644 --- a/tests/test_config/test_loader.py +++ b/tests/test_config/test_loader.py @@ -58,6 +58,7 @@ def test_resolve_missing_required_env_var_raises(self) -> None: resolve_env_vars("${REQUIRED_VAR}") assert "REQUIRED_VAR" in str(exc_info.value) assert "not set" in str(exc_info.value) + assert "${REQUIRED_VAR:-default_value}" in str(exc_info.value) def test_resolve_empty_default(self) -> None: """Test that empty default is allowed."""