From c4068efd54ce601f6e39575a45f048f413fb5300 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 29 Aug 2026 08:29:40 +0800 Subject: [PATCH] autoresearch iter 10: keep error identity at the last errorlint sites RunPushTest flattened channel validation failures with %v, telegram's fallback path discarded the original send error, and the config loader's type assertion on viper.ConfigFileNotFoundError would miss a wrapped form and fatally abort over a merely missing file. errorlint now reports zero. --- backend/pkg/config/config.go | 4 +++- backend/plugins/domain/message_gateway/push/telegram.go | 2 +- backend/plugins/domain/message_gateway/service/push.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/pkg/config/config.go b/backend/pkg/config/config.go index 679c0ff6..52e18829 100644 --- a/backend/pkg/config/config.go +++ b/backend/pkg/config/config.go @@ -6,6 +6,7 @@ package config import ( "encoding/json" + "errors" "flag" "log" "os" @@ -67,7 +68,8 @@ func init() { // 读取配置文件(可选:找不到文件时使用空默认值 + 环境变量) if err := viper.ReadInConfig(); err != nil { - if _, ok := err.(viper.ConfigFileNotFoundError); !ok { + var notFound viper.ConfigFileNotFoundError + if !errors.As(err, ¬Found) { // 文件存在但读取/解析失败 if _, statErr := os.Stat(configPath); statErr == nil { //nolint:gosec // configPath is loaded from CONFIG_PATH environment variable log.Fatalf("[Config] read config failed: %v\n", err) diff --git a/backend/plugins/domain/message_gateway/push/telegram.go b/backend/plugins/domain/message_gateway/push/telegram.go index 11162763..3772808e 100644 --- a/backend/plugins/domain/message_gateway/push/telegram.go +++ b/backend/plugins/domain/message_gateway/push/telegram.go @@ -76,7 +76,7 @@ func (p *TelegramPusher) Send(ctx context.Context, cfg Config, target string, bo } fallbackErr := p.sendMessage(ctx, baseURL, cfg.Secret, chatID, plainText, "") if fallbackErr != nil { - return "", fmt.Errorf("telegram: send message failed (fallback also failed): %w (original HTML error: %v)", fallbackErr, err) + return "", fmt.Errorf("telegram: send message failed (fallback also failed): %w (original HTML error: %w)", fallbackErr, err) } } diff --git a/backend/plugins/domain/message_gateway/service/push.go b/backend/plugins/domain/message_gateway/service/push.go index 009b063a..ddcc36eb 100644 --- a/backend/plugins/domain/message_gateway/service/push.go +++ b/backend/plugins/domain/message_gateway/service/push.go @@ -206,7 +206,7 @@ func RunPushTest(ctx context.Context, cfg pkgpush.Config, target string) error { return err } if err := pusher.ValidateConfig(cfg); err != nil { - return fmt.Errorf("%s: %v", errs.ErrValidationFailed, err) + return fmt.Errorf("%s: %w", errs.ErrValidationFailed, err) } ApplySMTPFallbackToPushConfig(ctx, &cfg)