Skip to content

fix: treat an existing file path as literal instead of a glob pattern - #4608

Open
Eljees wants to merge 1 commit into
aws-cloudformation:mainfrom
Eljees:fix/2136-literal-glob-in-template-path
Open

fix: treat an existing file path as literal instead of a glob pattern#4608
Eljees wants to merge 1 commit into
aws-cloudformation:mainfrom
Eljees:fix/2136-literal-glob-in-template-path

Conversation

@Eljees

@Eljees Eljees commented Aug 6, 2026

Copy link
Copy Markdown

Issue #, if available: Fixes #2136

Description of changes:

ConfigMixIn expands every template path through glob.glob(filename, recursive=True). When the path is a real file whose name contains glob metacharacters, the brackets are read as a character class instead of literal text: the glob matches nothing and the template is silently dropped, or the pattern blows up on a bad character range. The reported case is the file name pytest's snapshot plugin produces:

emr/tests/__snapshots__/test_snapshot[emr--tests--emr.template.2.yaml].yaml

The fix checks the literal path first — if Path(filename).is_file() it is used as-is, otherwise the existing glob expansion runs unchanged. Patterns keep working exactly as before; a path that already resolves to a file is simply never reinterpreted as a pattern.

Test: test_config_literal_path_with_glob_characters creates template[1].yaml in a temporary directory and asserts it survives into config.templates. It fails on main (the list comes back empty) and passes with the fix.

AI-assisted (LLM used for drafting and for running the checks); the analysis and the runs are mine.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Eljees

Eljees commented Aug 14, 2026

Copy link
Copy Markdown
Author

Ping — this has been open since 6 August with no review yet.

ConfigMixIn expands every template path through glob.glob(filename, recursive=True), so a path that is a real file whose name contains glob metacharacters gets read as a character class: the glob matches nothing and the template is silently dropped, or it fails on a bad character range. The reported case is the filename pytest's snapshot plugin produces, test_snapshot[emr--tests--emr.template.2.yaml].yaml. The fix checks Path(filename).is_file() first and otherwise runs the existing glob expansion unchanged, so patterns behave exactly as before.

No CI has run on it: the check suite for e54c80e is at action_required with zero runs, so it needs a maintainer to approve the workflow. The branch is also behind main by now — happy to rebase.

Happy to close it if you would rather fix #2136 another way.

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.

Unsafe call to glob causes error if filename contains special characters

1 participant