mpfaffenberger / mpfaffenberger/code_puppy

command_line/ swallows ~23 exceptions with bare 'except Exception: pass' — no logging, no narrow types

Open
#421 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
814
Forks
278
Avg merge
2d 5h
Merged PRs (30d)
76

Description

Problem

code_puppy/command_line/ swallows exceptions silently at scale: 65 except Exception: handlers in the directory (plus session_storage/status_display/terminal_utils), and at least 23 of them are immediately followed by bare pass with no logging. Hotspots:

  • prompt_toolkit_completion.py — 5 silent except Exception: pass (clipboard paste, key bindings, completion loading)
  • pin_command_completion.py — 5
  • command_handler.py — 3 (including the custom-command help aggregation at line 66, where a plugin raising during help generation silently removes the entire Custom Commands section)
  • session_storage.py:196-200 — metadata read failure during autosave restore silently renders unknown time / unknown size, masking corrupt metadata
  • session_storage.py:316-321, 327-331 — autosave-id update and history display failures vanish entirely

Representative example (command_handler.py:264-268):

if isinstance(res, str):
    try:
        emit_info(res)
    except Exception:
        pass
    return True

Some best-effort terminal-state resets in terminal_utils.py legitimately need broad suppression — those at least carry comments. But most of these sites suppress logic errors (plugin bugs, corrupt metadata, broken completers) with zero trace, which makes field debugging nearly impossible. "Errors should never pass silently. Unless explicitly silenced" — explicit silencing means narrow exception types and/or a debug log, not blanket pass.

Suggested fix

Triage each site into:

  1. Genuinely best-effort terminal/OS calls → keep, but narrow the type where possible (OSError, UnicodeError) and add a # best-effort: <why> comment.
  2. Plugin/callback boundaries → keep broad catch, but add logger.warning("plugin hook failed: %s", e, exc_info=True) so failures are visible in logs.
  3. Internal logic (metadata parsing, completion loading) → catch the narrow expected types (json.JSONDecodeError, OSError, KeyError) and log at debug.

A module-level logger = logging.getLogger(__name__) already exists in several of these files (e.g., clipboard.py does this correctly and logs every suppressed error — use it as the template).

Filed by Zen Reviewer C (code-puppy-60635a)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inventorying the handlers named in prompt_toolkit_completion.py, pin_command_completion.py, command_handler.py, and session_storage.py, using clipboard.py as the logging example. Triage each suppression according to the issue's three categories, then verify that logic failures are no longer silent while explicitly best-effort terminal operations remain documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.