pingcap / pingcap/tidb

Missing input validation could cause unexpected behavior with edge case inputs

Open
#69,562 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 functions do not validate their inputs before processing, which can lead to confusing error messages or silent failures when unexpected values are passed.

### Steps to Reproduce
1. Call the affected function with `None`, an empty string, or a negative number
2. Observe that the error message is not helpful or the function silently returns incorrect results

### Expected Behavior
Functions should validate inputs early and raise descriptive errors:

```python
def process(value):
if value is None:
raise ValueError("value must not be None")
if not isinstance(value, int):
raise TypeError(f"expected int, got {type(value).__name__}")
# ... rest of function
```

### Impact
This makes debugging harder for users of the library and can hide real bugs upstream.

### Suggested Fix
Add input validation at the start of public-facing functions with clear error messages.

Contributor guide

Open the contributing guide

Research direction

No affected function, file, or test is identified. Start by locating the public-facing functions involved and reproduce the cases with None, an empty string, and a negative number. Done means the affected functions reject invalid inputs with descriptive errors and no longer silently return incorrect results.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.