Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

fix(services): narrow bare except: → except Exception: in 4 Python services - #101

Open
jgluck96 wants to merge 1 commit into
mainfrom
fix/bare-except-remaining
Open

jgluck96 wants to merge 1 commit into
mainfrom
fix/bare-except-remaining

Conversation

@jgluck96

@jgluck96 jgluck96 commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Bare except: catches BaseException (including KeyboardInterrupt, SystemExit, GeneratorExit), which can mask fatal signals and make the process unkillable or silently swallow shutdown. Narrowing to except Exception: preserves the catch-all intent while letting system-exit exceptions propagate normally.

12 occurrences fixed across 4 files:

  • src/agent-api.py (3): JSON parse in /status, body parse in /voice/desired-state, body parse in /task-done
  • src/dashboard.py (2): git log date parse, outer catch-all fallback
  • src/discord-bridge.py (6): access.json reads (×4), tier detection, TOFU pairing
  • src/health-check.py (1): pgrep subprocess call

Mirrors upstream fix(bridges,services): narrow bare except: → except Exception: (sonichi#1398).

Test plan

  • 240/240 TypeScript tests pass
  • 27/27 Python tests pass

🤖 Generated with Claude Code

…rvices

Bare `except:` catches BaseException (including KeyboardInterrupt,
SystemExit, GeneratorExit) which can mask fatal signals and make
the process unkillable. Narrowing to `except Exception:` preserves
the catch-all intent while letting system-exit exceptions propagate.

Affected files (12 occurrences total):
- src/agent-api.py (3): JSON parse, body parse in HTTP handlers
- src/dashboard.py (2): git log parse, fallback return
- src/discord-bridge.py (6): access.json reads, tier detection
- src/health-check.py (1): pgrep subprocess call

240/240 TS + 27/27 Python tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@bassilkhilo-ag2 bassilkhilo-ag2 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct and safe. Narrowing bare except: to except Exception: across agent-api, dashboard, and discord-bridge is the right Python practice — bare except catches SystemExit and KeyboardInterrupt which we never want swallowed. All three call sites are in error-recovery paths where swallowing Exception is intentional. Approved.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants