Skip to content

fix(message_router): remove dead shadowed _sanitize_filename delegator - #2743

Merged
vybe merged 1 commit into
Abilityai:devfrom
Anai-Guo:fix/remove-shadowed-sanitize-filename
Sep 14, 2026
Merged

vybe merged 1 commit into
Abilityai:devfrom
Anai-Guo:fix/remove-shadowed-sanitize-filename

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

What

src/backend/adapters/message_router.py defines _sanitize_filename twice at module scope:

  • The first (lines ~309-310) is a one-line delegator to services.upload_service.sanitize_filename.
  • The second (the block under # Filename sanitization (Issue #487)) is the full hardened implementation (NFKC normalize, basename, safe-char stripping, hidden-dotfile rejection, length cap, collision dedup).

Python binds the later definition, so the delegator is dead code. pyflakes flags it:

message_router.py:318:1: redefinition of unused '_sanitize_filename' from line 309

Fix

Remove the dead delegator. Its only reference to the imported sanitize_filename symbol also disappears, so that name is dropped from the services.upload_service import.

No behavior change — the Issue #487 implementation is already the one that runs; this only deletes the unreachable earlier definition (and the now-unused import).

Verification

pyflakes on the patched file no longer reports the redefinition, and sanitize_filename is no longer imported-but-unused. +1 / -5, one file.

🤖 Generated with Claude Code

message_router.py defined _sanitize_filename twice at module scope. The
first definition is a one-line delegator to services.upload_service.
sanitize_filename; the second is the full hardened implementation added
for Issue Abilityai#487. Python binds the later definition, so the delegator was
dead code (pyflakes F811: redefinition of unused _sanitize_filename).

Removing it also drops the now-unused sanitize_filename import. No
behavior change: the Issue Abilityai#487 implementation was already the one that
ran.

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge-train: batch validated on train/20260914-0901 (train PR #2765, full suite green)

@vybe
vybe merged commit 9ceefb1 into Abilityai:dev Sep 14, 2026
25 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