Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

Fix/find files in dir (#488)

Thomas Hebrard4be0de3aa674
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c02c4b25b..0226bfd26 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+### Unreleased
+
+### Fixed
+
+- Fixed a bug in the `find_files_in_dir` function.
+
### [v0.17.0] - 2025-11-27
**Highlights:** - Previously, in the pipelex config files (`.toml` files in the `.pipelex/` directory, such as `.pipelex/pipelex.toml`, but also the routing profiles files, backends, etc.), when an array was overridden, the new array was concatenated to the old array. Now, the new array overrides the old array.
diff --git a/pipelex/tools/misc/file_utils.py b/pipelex/tools/misc/file_utils.py
index 28c0c1f78..7854aa795 100644
--- a/pipelex/tools/misc/file_utils.py
+++ b/pipelex/tools/misc/file_utils.py
@@ -361,12 +361,13 @@ def find_files_in_dir(dir_path: str, pattern: str, is_recursive: bool = True, ex
"""
path = Path(dir_path)
files: list[Path] = []
+ filtered_files: list[Path] = []
if is_recursive:
files = list(path.rglob(pattern))
else:
files = list(path.glob(pattern))
for file in files:
- if excluded_dirs is not None and any(part in excluded_dirs for part in file.parts):
- files.remove(file)
- return files
+ if excluded_dirs is None or not any(part in excluded_dirs for part in file.parts):
+ filtered_files.append(file)
+ return filtered_files