Summary
Enable the ruff BLE (flake8-blind-except) rule family in pyproject.toml to eliminate blind except Exception catches across mcpgateway/.
Current State
The BLE rules are not currently in the ruff select list. A scan of mcpgateway/ shows 1,035 violations:
| Rule |
Count |
Fixable |
Description |
| BLE001 |
1,035 |
No |
Blind except Exception — catches overly broad exception types |
None are auto-fixable; each requires manual review.
Why
- Correctness: Blind except Exception can swallow unexpected errors (e.g., KeyboardInterrupt is excluded, but SystemExit, programming bugs like TypeError/AttributeError, and resource errors like MemoryError can be silently caught).
- Debuggability: Overly broad catches mask root causes and make debugging harder. Catching specific exceptions makes error handling intent explicit.
- Security: In a gateway/proxy context, silently swallowing errors can hide security-relevant failures (auth errors, injection attempts, resource exhaustion).
Plan
- Add "BLE" to the ruff select list in pyproject.toml
- Triage the 1,035 violations — categorize by intent:
- Narrow the catch: Replace with specific exception types where the expected failure mode is known
- Justified broad catch: Add # noqa: BLE001 with a comment explaining why broad catching is intentional (e.g., top-level error boundaries, plugin isolation)
- Remove entirely: Some catches may be unnecessary defensive code that should just let the exception propagate
- Verify with make flake8 verify
Given the volume, this should be split across multiple PRs by subdirectory or functional area (e.g., services/, routers/, transports/, middleware/).
Reactions are currently unavailable
Summary
Enable the ruff BLE (flake8-blind-except) rule family in pyproject.toml to eliminate blind except Exception catches across mcpgateway/.
Current State
The BLE rules are not currently in the ruff select list. A scan of mcpgateway/ shows 1,035 violations:
None are auto-fixable; each requires manual review.
Why
Plan
Given the volume, this should be split across multiple PRs by subdirectory or functional area (e.g., services/, routers/, transports/, middleware/).