Skip to content

fix(code): apply the Text file-name rule in CodeFileTypeContentFilter - #575

Open
raams95 wants to merge 1 commit into
OpenDCAI:mainfrom
raams95:fix/code-filetype-text-filename-rule
Open

raams95 wants to merge 1 commit into
OpenDCAI:mainfrom
raams95:fix/code-filetype-text-filename-rule

Conversation

@raams95

@raams95 raams95 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary

CodeFileTypeContentFilter documents a file-name rule for Text files (keep README/notes/todo/description/CMakeLists and requirements files), but "text" is also in SIZE_CHECK_TYPES, and the size check returned first in the if / elif chain. So _is_text_filename_valid() never ran, and every Text file under 512 lines was kept whatever its name (e.g. random_dump.txt).

Fix

Reject large files first, then apply the per-type rules, so Text files get both the size check and the file-name check. JSON/YAML/other size-checked types and HTML behave as before.

Tests

Added test/cpu_only/test_code_file_type_content_filter.py:

  • Text files follow the file-name rule: fails before the fix (random_dump.txt kept), passes after.
  • Text files still have to pass the size check.
  • Other size-checked types (JSON) and unchecked types are unchanged.
pytest -m "cpu or api" test/cpu_only/test_code_file_type_content_filter.py -q
3 passed

Fixes #574

"text" is in SIZE_CHECK_TYPES, and the size check returned before the
Text file-name check, so that check never ran and every small Text file
was kept whatever its name. Reject large files first and then apply the
file-type rules, so Text files get both checks.

Fixes OpenDCAI#574

This branch has not been deployed

No deployments
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.

CodeFileTypeContentFilter never applies the Text file-name rule

1 participant