Skip to content

fix: validate file extensions in python_check before running linters#6

Open
gszep wants to merge 1 commit intomicrosoft:mainfrom
gszep:main
Open

fix: validate file extensions in python_check before running linters#6
gszep wants to merge 1 commit intomicrosoft:mainfrom
gszep:main

Conversation

@gszep
Copy link

@gszep gszep commented Feb 16, 2026

Summary

  • Added file extension validation in PythonChecker.check_files() to reject non-Python files before invoking ruff/pyright
  • Non-Python files (.ts, .js, etc.) return an informative NON_PYTHON info-level issue instead of garbage linter output
  • Directories and .py/.pyi files pass through normally

Problem

During an Amplifier session, the LLM called python_check on TypeScript files. Without any file extension validation, ruff and pyright ran against .ts files and produced 228K+ characters of nonsensical output (907 garbage issues). This single tool call consumed ~30% of the Claude context budget, ultimately triggering a failure that crashed the session.

Fix

Added validation in PythonChecker.check_files() -- the shared code path that protects all callers (tool module, hook module, and CLI):

  • All-non-Python paths: Returns immediately with info-level messages listing skipped files -- no linters invoked
  • Mixed paths: Filters out non-Python files (reported as skipped), runs linters only on valid .py/.pyi files and directories
  • All-Python paths: No behavior change

Test plan

  • Non-Python files (.ts, .js) are rejected with clear NON_PYTHON info message
  • Mixed paths filter out non-Python files and still check valid Python files
  • Pure Python files and directories work unchanged
  • Existing tests pass

Reject non-Python files (.ts, .js, etc.) upfront in PythonChecker.check_files()
instead of feeding them to ruff/pyright. When called on TypeScript files,
linters produced 228K+ chars of garbage output that exhausted the Claude
CLI context budget. Non-Python files now get a clear info-level message
while directories and .py/.pyi files pass through normally.

The validation sits in the shared checker code path, protecting all
callers (tool, hook, CLI).

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
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.

1 participant