You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*: fix potential bug by ai in pkg/schedule/schedulers (#10312)
close#10449
- It removes several unsafe type assertions on JSON input (like input["x"].(string)), replacing them with checked parsing and clear 400 Bad Request responses, so malformed payloads no longer panic PD.
- Key places: pkg/schedule/schedulers/balance_range.go, pkg/schedule/schedulers/evict_leader.go, pkg/schedule/schedulers/grant_hot_region.go, pkg/schedule/schedulers/grant_leader.go
- It fixes a risky type cast in transfer witness handling by making RecvRegionInfo safe (nil on wrong scheduler type) and guarding before channel send.
- pkg/schedule/schedulers/transfer_witness_leader.go, pkg/schedule/schedulers/scheduler_controller.go
- It corrects HTTP error behavior in scheduler API paths:
- invalid user options now return 400 instead of 500
- avoids nil dereference when delete redirect fails and response is nil
- handles “handler unavailable” cases explicitly
- server/api/scheduler.go
- It adds regression tests specifically asserting no panic and expected status codes for bad/odd inputs.
- pkg/schedule/schedulers/balance_range_test.go, pkg/schedule/schedulers/evict_leader_test.go, pkg/schedule/schedulers/grant_hot_region_test.go, pkg/schedule/schedulers/grant_leader_test.go, pkg/schedule/schedulers/transfer_witness_leader_test.go
Signed-off-by: tongjian <1045931706@qq.com>
Signed-off-by: bufferflies <1045931706@qq.com>
0 commit comments