fix(admin): propagate cache errors in FlushTaskExecutionLog

缓存故障(非 ErrCacheMiss)不再被静默吞掉:上抛包装错误,避免缓冲任务日志丢失并误报持久化成功;
ErrCacheMiss 仍视为无日志的正常路径。附 3 个回归测试(故障/未命中/持久化+清理)。
lint_issues 34→33 (nilerr 清零)
This commit is contained in:
ryan
2026-08-28 16:50:03 +08:00
parent cf85a56aa7
commit 6e12a7fd5d
2 changed files with 123 additions and 1 deletions
+10 -1
View File
@@ -4,6 +4,7 @@
package admin
import (
"Wavelet/core/contracts"
"Wavelet/pkg/cache/ram"
"Wavelet/pkg/idgen"
"Wavelet/pkg/util"
@@ -502,7 +503,15 @@ func FlushTaskExecutionLog(ctx context.Context, taskID string) error {
key := taskExecutionLogRedisKey(taskID)
var logText string
if err := cacheSvc.Get(ctx, key, &logText); err != nil || logText == "" {
if err := cacheSvc.Get(ctx, key, &logText); err != nil {
// 缓存未命中属于正常情况(任务无输出),其余错误必须上抛,
// 否则缓冲日志会被静默丢弃并误报持久化成功。
if !errors.Is(err, contracts.ErrCacheMiss) {
return fmt.Errorf("load buffered task execution log: %w", err)
}
return nil
}
if logText == "" {
return nil
}