From a5b2f66145dbd73ecfdd97c3bd936ce47e08c409 Mon Sep 17 00:00:00 2001 From: venti <1308199824@qq.com> Date: Sat, 30 May 2026 16:37:39 +0800 Subject: [PATCH] fix(config): use safe_substitute to prevent crashes on $ in config values (fixes #2349) --- .../graphrag-common/graphrag_common/config/load_config.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/graphrag-common/graphrag_common/config/load_config.py b/packages/graphrag-common/graphrag_common/config/load_config.py index c8929149f1..73c110a2ac 100644 --- a/packages/graphrag-common/graphrag_common/config/load_config.py +++ b/packages/graphrag-common/graphrag_common/config/load_config.py @@ -84,11 +84,7 @@ def _get_parser_for_file(file_path: str | Path) -> Callable[[str], dict[str, Any def _parse_env_variables(text: str) -> str: """Parse environment variables in the configuration text.""" - try: - return Template(text).substitute(os.environ) - except KeyError as error: - msg = f"Environment variable not found: {error}" - raise ConfigParsingError(msg) from error + return Template(text).safe_substitute(os.environ) def _recursive_merge_dicts(dest: dict[str, Any], src: dict[str, Any]) -> None: