Skip to content

fix: replace 16 bare excepts with except Exception across 9 files#205

Open
haosenwang1018 wants to merge 1 commit intoHKUDS:mainfrom
haosenwang1018:fix/bare-excepts
Open

fix: replace 16 bare excepts with except Exception across 9 files#205
haosenwang1018 wants to merge 1 commit intoHKUDS:mainfrom
haosenwang1018:fix/bare-excepts

Conversation

@haosenwang1018
Copy link

Replace bare except: with except Exception: across 9 files (16 sites).

Why: Bare except: catches BaseException including KeyboardInterrupt and SystemExit, which can prevent clean shutdown and mask critical errors. Using except Exception: preserves all existing fallback behavior while allowing system exceptions to propagate.

Files changed:

  • scripts/generate_roster.py — pagination fallback
  • scripts/start_web.py — port check fallback
  • src/agents/research/agents/reporting_agent.py — citation parsing (2 sites)
  • src/api/routers/knowledge.py — progress tracking (3 sites)
  • src/api/utils/task_id_manager.py — task cleanup
  • src/knowledge/start_kb.py — service startup
  • src/logging/adapters/lightrag.py — logger setup (2 sites)
  • src/logging/logger.py — log formatting (2 sites)
  • src/tools/tex_downloader.py — file extraction (3 sites)
Bare `except:` catches BaseException including KeyboardInterrupt and
SystemExit, which can mask critical errors and prevent clean shutdowns.
This replaces 16 bare except clauses across 10 files with
`except Exception:` to only catch non-system exceptions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant