
kevin9327andClaude Opus 5
68005c92e6
fix(alerts): 触发记录查询的 days/limit 补上范围约束
GET /api/alerts 的 days、limit 是裸 int,没有任何约束,越界值不报错而是
静默返回错误结果:
- days=-1 → cutoff 被推到未来,200 但 alerts 为空(total 仍是 3)
- limit=-1 → out[:limit] 变成负数切片,3 条记录只返回 2 条,
静默丢掉最旧一条,调用方无从察觉
- limit=0 → 200 但 alerts 为空
同类列表端点已有正确写法:abnormal.py 用 `limit: int = Query(500, ge=1,
le=2000)`,rps.py 用 `days: int = Query(12, ge=7, le=30)`,越界直接 422。
本次把 /api/alerts 补齐到同一口径,上下限取存储侧保留策略本身
(alert_store.MAX_DAYS / MAX_RECORDS),不新增常量,超出保留窗口的请求
本来也没有可返回的数据。
前端 alertsList 实际只传 days=7、limit=1/10/500,全部落在新区间内;
新增的 tests/test_alerts_query_bounds.py 同时锁住这些合法取值仍返回 200
且记录条数不变。
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 07:37:17 +09:00
..
2026-09-05 20:33:31 +08:00
2026-08-30 19:05:13 +08:00
2026-08-30 19:05:32 +08:00
2026-09-05 15:41:15 +08:00
2026-09-04 12:03:06 +08:00
2026-07-18 18:31:02 +08:00
2026-09-04 12:50:50 +08:00
2026-08-13 20:16:02 +08:00
2026-09-09 07:37:17 +09:00
2026-08-30 19:05:27 +08:00
2026-08-30 19:05:31 +08:00
2026-08-05 17:56:27 +08:00
2026-09-05 15:41:15 +08:00
2026-07-12 13:52:49 +08:00
2026-09-03 13:26:42 +08:00
2026-09-05 22:49:52 +08:00
2026-09-05 22:49:52 +08:00
2026-08-02 10:56:03 +08:00
2026-08-02 10:56:03 +08:00
2026-08-02 10:56:03 +08:00
2026-08-05 17:56:27 +08:00
2026-09-03 13:20:59 +08:00
2026-09-05 22:49:52 +08:00
2026-08-23 19:36:00 +08:00
2026-07-25 22:51:27 +08:00
2026-08-30 19:05:20 +08:00
2026-09-05 15:41:15 +08:00
2026-09-05 15:41:15 +08:00
2026-09-05 15:41:15 +08:00
2026-07-26 18:35:31 +08:00
2026-08-23 19:13:03 +08:00
2026-09-05 15:41:15 +08:00
2026-08-16 23:39:07 +08:00
2026-09-02 20:20:38 +08:00
2026-07-08 13:42:53 +08:00
2026-08-30 19:05:32 +08:00
2026-08-30 19:05:29 +08:00
2026-09-04 12:40:04 +08:00
2026-09-07 15:25:27 +08:00
2026-09-03 13:01:43 +08:00
2026-08-16 23:39:07 +08:00
2026-09-05 15:41:15 +08:00
2026-09-06 23:16:27 +08:00
2026-08-16 23:39:07 +08:00
2026-08-16 23:39:07 +08:00
2026-09-07 08:10:38 +09:00
2026-09-07 08:07:02 +09:00
2026-07-18 00:49:28 +08:00
2026-09-06 18:27:33 +08:00
2026-07-16 14:34:07 +08:00
2026-09-04 11:53:15 +08:00
2026-09-07 22:54:05 +08:00
2026-09-03 13:45:12 +08:00
2026-09-08 19:56:03 +09:00
2026-07-31 19:56:33 +08:00
2026-08-30 18:51:24 +09:00
2026-08-26 00:54:39 +08:00
2026-09-05 15:41:15 +08:00
2026-09-05 15:41:15 +08:00
2026-09-05 15:41:15 +08:00
2026-09-05 15:41:15 +08:00
2026-08-16 23:39:07 +08:00
2026-09-06 18:27:33 +08:00
2026-09-06 18:27:33 +08:00
2026-09-05 15:41:15 +08:00
2026-07-19 16:42:03 +08:00
2026-08-30 19:05:25 +08:00
2026-08-16 23:39:07 +08:00
2026-09-06 17:39:43 +08:00
2026-08-30 19:05:26 +08:00
2026-09-06 17:39:43 +08:00
2026-08-16 23:39:07 +08:00
2026-08-16 23:39:07 +08:00
2026-07-16 12:17:27 +08:00
2026-08-16 23:39:07 +08:00
2026-07-31 19:38:36 +08:00
2026-08-30 22:29:33 +08:00
2026-08-30 22:29:33 +08:00
2026-09-06 18:26:29 +08:00
2026-08-30 19:05:27 +08:00
2026-09-01 22:42:59 +08:00
2026-09-03 17:35:16 +08:00
2026-09-08 18:09:59 +08:00
2026-08-16 23:39:07 +08:00
2026-09-08 18:09:59 +08:00
2026-09-08 18:09:59 +08:00
2026-08-16 23:39:07 +08:00
2026-07-18 00:49:28 +08:00
2026-07-28 09:46:51 +08:00
2026-09-02 20:20:38 +08:00
2026-08-16 23:39:07 +08:00
2026-09-04 11:59:00 +08:00
2026-08-16 23:39:07 +08:00
2026-09-03 13:01:43 +08:00
2026-08-16 23:39:07 +08:00
2026-08-16 23:39:07 +08:00
2026-08-26 13:19:16 +08:00
2026-08-16 23:39:07 +08:00
2026-08-16 23:39:07 +08:00
2026-08-16 23:39:07 +08:00
2026-08-16 23:39:07 +08:00
2026-08-16 23:39:07 +08:00
2026-08-30 19:05:25 +08:00
2026-08-16 23:39:07 +08:00
2026-08-31 22:53:24 +08:00
2026-09-08 18:09:59 +08:00
2026-08-30 19:05:11 +08:00
2026-08-30 19:05:25 +08:00
2026-07-08 12:12:29 +08:00
2026-08-22 20:26:34 +08:00
2026-07-28 21:13:10 +08:00
2026-09-05 21:14:53 +09:00
2026-09-04 16:37:06 +08:00
2026-08-16 23:39:07 +08:00
2026-07-09 17:38:44 +08:00
2026-09-04 16:37:06 +08:00
2026-08-30 18:38:24 +09:00
2026-09-07 15:25:41 +08:00
2026-09-04 16:37:06 +08:00
2026-08-16 23:39:07 +08:00
2026-07-19 09:36:55 +08:00
2026-07-19 10:06:26 +08:00
2026-07-28 21:13:10 +08:00
2026-08-30 19:05:21 +08:00
2026-09-07 22:01:12 +08:00
2026-08-16 23:39:07 +08:00
2026-07-19 10:06:26 +08:00
2026-07-30 13:09:07 +08:00
2026-08-30 19:05:27 +08:00
2026-08-16 23:39:07 +08:00
2026-09-04 12:19:35 +08:00
2026-08-16 23:39:07 +08:00
2026-07-26 18:35:31 +08:00
2026-09-06 16:20:42 +08:00
2026-09-04 11:59:00 +08:00
2026-09-07 15:25:54 +08:00
2026-09-07 15:25:54 +08:00
2026-08-31 22:53:12 +08:00
2026-09-03 13:26:42 +08:00
2026-09-03 13:45:12 +08:00
2026-09-07 15:25:54 +08:00
2026-08-31 16:50:21 +08:00
2026-08-16 23:39:07 +08:00
2026-08-16 23:39:07 +08:00
2026-09-05 15:41:15 +08:00
2026-07-26 18:35:31 +08:00
2026-09-02 10:53:08 +08:00
2026-08-13 20:16:02 +08:00
2026-07-20 13:01:03 +08:00
2026-08-23 19:29:44 +08:00
2026-07-22 11:21:13 +08:00
2026-08-13 20:16:02 +08:00
2026-08-26 09:36:06 +08:00
2026-09-04 16:37:06 +08:00
2026-08-13 20:16:02 +08:00
2026-09-06 13:41:51 +08:00
2026-07-16 12:17:27 +08:00
2026-08-13 20:16:02 +08:00
2026-08-23 19:36:00 +08:00
2026-09-07 15:25:48 +08:00
2026-09-07 15:25:54 +08:00
2026-08-13 20:16:02 +08:00
2026-08-13 20:16:02 +08:00
2026-08-31 22:53:24 +08:00
2026-08-25 14:07:16 +08:00
2026-09-07 15:25:41 +08:00
2026-09-05 21:11:44 +09:00
2026-07-26 18:35:31 +08:00
2026-08-20 16:15:13 +08:00
2026-09-05 21:11:44 +09:00
2026-09-05 21:11:44 +09:00
2026-09-04 16:37:06 +08:00
2026-09-07 15:25:41 +08:00