autoresearch iter 14: stop a cache read error from clobbering the buffered task log

AppendTaskExecutionLog discarded the error from its read of the buffer, so a
transient cache failure looked like an empty buffer and the very next write
replaced the whole accumulated log with just the newest line. Flush already
distinguished miss from failure; append now does the same.
This commit is contained in:
ryan
2026-08-29 08:38:55 +08:00
parent 00ab727791
commit 6932b54a30
2 changed files with 43 additions and 1 deletions
@@ -125,7 +125,13 @@ func AppendTaskExecutionLog(ctx context.Context, taskID, logLine string) error {
key := TaskExecutionLogRedisKey(taskID)
var existing string
_ = cacheSvc.Get(ctx, key, &existing)
if err := cacheSvc.Get(ctx, key, &existing); err != nil {
// 只有未命中才代表「尚无缓冲」;其余读取失败若被当作空缓冲继续写入,
// 会用这一行覆盖掉整段已缓冲的任务日志。
if !errors.Is(err, contracts.ErrCacheMiss) {
return fmt.Errorf("load buffered task execution log: %w", err)
}
}
return cacheSvc.Set(ctx, key, existing+line, taskExecutionLogExpiration)
}