fix: 手动触发全部成功时被误报为失败

trigger 接口的 fails 是 nil 切片,无失败时序列化成 JSON null,
前端读 failed.length 抛异常并落入 catch 分支,把成功显示成"触发失败"。
改为初始化空切片,前端同时加空值兜底。

顺带修复 logstore.trim 用 First 查询保留位置,日志未超出保留条数时
返回 ErrRecordNotFound,导致每写一条日志都刷一行 gorm 警告。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
mei
2026-07-26 22:34:29 +08:00
co-authored by Claude Fable 5
parent d5ede38848
commit 0d766020bc
4 changed files with 19 additions and 12 deletions
+6 -3
View File
@@ -57,11 +57,14 @@ func HandleTriggerTimer(c *gin.Context) {
defer cancel()
// 并发执行所有规则,收集失败信息
//
// fails 必须初始化为空切片:nil 切片会被序列化成 JSON null,
// 前端读 failed.length 时会抛异常,把全部成功误报成触发失败。
var (
wg sync.WaitGroup
mu sync.Mutex
fails []string
wg sync.WaitGroup
mu sync.Mutex
)
fails := []string{}
for i := range rules {
rule := rules[i]
wg.Add(1)