Skip to content

fix: match file filters against paths relative to the repository root - #624

Merged
sng-asyncfunc merged 1 commit into
AsyncFuncAI:mainfrom
lbarrosby:fix/file-filters-relative-to-root
Nov 6, 2026
Merged

sng-asyncfunc merged 1 commit into
AsyncFuncAI:mainfrom
lbarrosby:fix/file-filters-relative-to-root

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

iterate_files passes the absolute file path to _should_process_file, which then checks excluded_dirs and included_dirs against every part of Path.resolve().parts. So the rules also match the directories above the repository root:

  • A local repository under /tmp/..., .../build/..., .../docs/..., .../out/..., .../bin/... (all in the default excluded_dirs) gets every file excluded. The wiki structure gets an empty file tree and indexing ends with "No valid documents with embeddings found".
  • included_dirs=["src"] includes every file when the repository itself lives under some src/ directory.

tests/conftest.py already works around this by removing ./tmp/ and ./temp/ from the config, since pytest's tmp_path sits under /tmp on Linux.

The fix compares the rules with the path relative to the root (p.relative_to(root_dir)), which iterate_files already computed for its return value. Both callers (read_all_documents and the wiki structure tree) go through iterate_files, so they keep matching each other.

Tests

Added two cases to tests/test_config.py, using the real default file_filters (no exclude_test_config fixture):

  • repository root under tmp/, build/ and docs/ parents keeps its files;
  • included_dirs=["folder"] with the root under a folder/ parent only returns folder/code.py.

All four fail on main (empty set / extra file) and pass with the change. pytest tests/test_config.py tests/backend: same 7 pre-existing failures in test_wiki_tasks_api.py before and after, everything else passes. ruff check and ruff format --check are clean.

This touches the same lines as #593 (nested directory rules). The two are independent, but whichever lands second needs a small rebase.

iterate_files passed absolute paths to _should_process_file, so the
excluded and included directory rules were checked against every
directory above the repository too. A local repository under /tmp,
build or docs had every file excluded, and included_dirs matched all
files when the root sat under a directory with the same name.

Compare the rules with the path relative to the root instead.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@sng-asyncfunc
sng-asyncfunc merged commit 10e1be1 into AsyncFuncAI:main Nov 6, 2026
3 checks passed
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.

2 participants