Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/vouch/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ def load_config(store: KBStore) -> InboxConfig:
return InboxConfig(
enabled=coerce_bool(raw.get("enabled", True), True),
min_chars=int(raw.get("min_chars", DEFAULT_MIN_CHARS)),
# lowercase to match scan()'s `path.suffix.lower()` compare — the file
# side is already case-folded, so a verbatim ".MD" here would match no
# file at all and silently skip the whole inbox.
extensions=(
tuple(str(e) for e in extensions)
tuple(str(e).lower() for e in extensions)
if isinstance(extensions, list)
else DEFAULT_EXTENSIONS
),
Expand Down
18 changes: 18 additions & 0 deletions tests/test_inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ def test_scan_skips_short_files_and_foreign_extensions(store: KBStore) -> None:
assert sorted(result.skipped) == ["binary.png", "tiny.md"]


def test_load_config_lowercases_configured_extensions(store: KBStore) -> None:
"""Regression: scan() matches `path.suffix.lower()`, so a verbatim
uppercase ".MD" in config matched no file at all and silently skipped the
whole inbox. load_config must case-fold configured extensions to the file
side, the same way `enabled: "false"` coercion is handled defensively."""
store.config_path.write_text(
store.config_path.read_text(encoding="utf-8")
+ '\ninbox:\n extensions: [".MD", ".TXT"]\n',
encoding="utf-8",
)
assert inbox.load_config(store).extensions == (".md", ".txt")

_drop(store, "notes.md")
result = inbox.scan(store, store.root / "inbox")
assert len(result.proposed) == 1
assert result.skipped == []


def test_scan_disabled_via_config_is_noop(store: KBStore) -> None:
store.config_path.write_text(
store.config_path.read_text(encoding="utf-8") + "\ninbox:\n enabled: false\n",
Expand Down
Loading