pingcap / pingcap/tidb

Exception type too broad in error handling

Open
#69,545 0 comments 0 reactions 0 assignees View on GitHub
contribution
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### Description
Some `except` clauses catch overly broad exception types (e.g., bare `except:` or `except Exception:`), which can accidentally swallow important errors like `KeyboardInterrupt` or `SystemExit`.

### Example
```python
# Problematic:
try:
do_something()
except: # catches EVERYTHING including KeyboardInterrupt
pass

# Better:
try:
do_something()
except ValueError as e:
logger.warning(f"Value error: {e}")
```

### Expected Behavior
Exception handlers should catch only the specific exceptions they know how to handle.

### Impact
- Makes it impossible to interrupt the program with Ctrl+C in some cases
- Hides unexpected errors that should be investigated
- Makes debugging significantly harder

### Suggested Fix
Replace broad `except` clauses with specific exception types wherever possible.

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named, and the examples use Python while TiDB is a Go repository. First confirm how the reported broad error handling appears in this codebase, then identify the affected handlers and any existing tests. Done means in-scope handlers no longer swallow errors outside the cases they can safely handle, with relevant tests still passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.