FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[CHORE][PYTHON]: Enable ruff BLE001 rule to tighten bare exception handling · Issue #3348 · IBM/mcp-context-forge · GitHub

[CHORE][PYTHON]: Enable ruff BLE001 rule to tighten bare exception handling #3348

Description

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

  1. Add "BLE" to the ruff select list in pyproject.toml
  2. 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
  3. 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/).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SHOULDP2: Important but not vital; high-value items that are not crucial for the immediate releasechoreLinting, formatting, dependency hygiene, or project maintenance chorespythonPython / backend development (FastAPI)securityImproves security

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL