Skip to content

fix: preserve literal dollar signs in config parsing#2418

Open
Kevin-Li-2025 wants to merge 1 commit into
microsoft:mainfrom
Kevin-Li-2025:kevin/fix-config-dollar-literals
Open

fix: preserve literal dollar signs in config parsing#2418
Kevin-Li-2025 wants to merge 1 commit into
microsoft:mainfrom
Kevin-Li-2025:kevin/fix-config-dollar-literals

Conversation

@Kevin-Li-2025

Copy link
Copy Markdown

Summary

  • preserve literal $ characters in config values such as regex anchors while still expanding valid environment variables
  • keep the existing missing-env-var failure behavior for valid $VAR and ${VAR} placeholders
  • add a regression test for a YAML regex pattern ending in $

Fixes #2349.

Root cause

string.Template.substitute() treats every $ as the start of a template placeholder and raises ValueError for a bare regex anchor like .*\.md$. The loader only needs strict validation for valid env-var placeholders; other $ characters should remain literal config content.

Tests

  • uv run --package graphrag-common pytest tests/unit/load_config/test_load_config.py -q
  • uv run ruff check packages/graphrag-common/graphrag_common/config/load_config.py tests/unit/load_config/test_load_config.py
  • uv run ruff format --check packages/graphrag-common/graphrag_common/config/load_config.py tests/unit/load_config/test_load_config.py
  • git diff --check

@Kevin-Li-2025 Kevin-Li-2025 requested a review from a team as a code owner June 27, 2026 10:58
@Kevin-Li-2025

Copy link
Copy Markdown
Author

Thanks for taking a look. I noticed after opening this that #2363 also addresses #2349 and keeps missing environment variable references as explicit errors while preserving literal $ characters.

This PR is a smaller current-base variant of the same fix with a focused regression test. I am happy to close this in favor of #2363 if maintainers prefer that existing PR; otherwise this is ready as an alternative patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: string.Template.substitute() crashes on $ in config values like regex file_pattern

1 participant