pathbase parse can crash while scanning environment-backed templates if the process environment includes shell function exports or other non-template values that happen to contain ${...} and path-like text.
Observed behavior:
A shell-exported value such as BASH_FUNC_module%% was treated as a candidate template, which led to regex compilation failing with re.error: bad character in group name ... during match_template() / find_matching_templates().
Expected behavior:
- Only real pathbase templates should be considered during environment template matching. Invalid or unrelated env entries should be skipped without crashing the CLI.
Root cause:
- Template candidate detection was too permissive, and regex compilation errors were not normalized into InvalidTemplateError, so malformed env-derived template strings could escape as uncaught re.error.
Fix:
- Tighten env template detection to require actual Python format fields.
- Treat regex compilation failures as invalid templates and skip them.
- Add a regression test covering shell-function-style env pollution.
pathbase parse can crash while scanning environment-backed templates if the process environment includes shell function exports or other non-template values that happen to contain
${...}and path-like text.Observed behavior:
A shell-exported value such as
BASH_FUNC_module%%was treated as a candidate template, which led to regex compilation failing with re.error: bad character in group name ... duringmatch_template()/find_matching_templates().Expected behavior:
Root cause:
Fix: