Skip to main content
ai-slop/python-broad-exceptmanual fix

Broad except with pass.

`except Exception: pass` (or `BaseException`): a handler that catches every ordinary error and does nothing with it. The failure leaves no trace.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

python-broad-except.py
✗ Flagged
def sync_user(user_id):
    try:
        profile = crm.fetch_profile(user_id)
        db.save_profile(profile)
    except Exception:
        pass
Why this trips

Deterministic line match: flags `except Exception:` or `except BaseException:` (with or without `as e`) when the next line is `pass`, or a comment followed by `pass`.

python-broad-except.py
✓ Clean
def sync_user(user_id):
    try:
        profile = crm.fetch_profile(user_id)
    except crm.NotFound:
        logger.info("no CRM profile for user %s", user_id)
        return
    db.save_profile(profile)
What changed

Narrow the exception class, log the error with context, or re-raise. If swallowing is genuinely intended, name the specific failure being ignored and why.

Agents add a catch-all to get past an error they hit once while generating, then fill the body with `pass` because they have no plan for the failure.

How this rule is justified.

Rule id

ai-slop/python-broad-except

Enforcing engine

ai-slop

Detector strategy

Deterministic line match: flags `except Exception:` or `except BaseException:` (with or without `as e`) when the next line is `pass`, or a comment followed by `pass`.

Legitimate code that is NOT flagged

Broad handlers that log, re-raise, return, or do any other work are not flagged, and neither are narrow handlers such as `except ValueError: pass`.

Evidence

Part of aislop's Python rule set, scored in the standard tier because broad handling is risky but sometimes intentional at boundaries.