Skip to content

fix: use safe_substitute in config loader to avoid crash on $ in values (fixes #2349)#2380

Open
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-2349-template-safe-substitute
Open

fix: use safe_substitute in config loader to avoid crash on $ in values (fixes #2349)#2380
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-2349-template-safe-substitute

Conversation

@hanhan761
Copy link
Copy Markdown

Summary

Replaces string.Template.substitute() with safe_substitute() in the config loader so that bare $ characters (e.g. in regex file_pattern values) don't crash the entire pipeline.

Issue

Closes #2349

Root Cause

Template.substitute() raises ValueError on any $ not followed by a valid placeholder identifier. Config values like file_pattern: '.*\\.md$' trigger this.

Fix

Replace substitute() with safe_substitute(), which leaves unrecognized placeholders as literal text.

Verification

  • Dollar sign in regex anchor: preserved as-is
  • \ substitution: still works
  • Missing env var : left as literal text, no crash

@hanhan761 hanhan761 requested a review from a team as a code owner May 30, 2026 08:49
…rsing

Template(text).substitute(os.environ) crashes on bare $ characters in
config values (e.g. regex file_pattern ending with $). Changed to
safe_substitute() which leaves unrecognized placeholders as literal text.

Fixes microsoft#2349
@hanhan761 hanhan761 force-pushed the fix-2349-template-safe-substitute branch from 1b3ffb3 to d17153e Compare May 30, 2026 12:54
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