fix: retain knowledge indexing errors and explain failure causes

This commit is contained in:
Ed1s0nZ committed 2026-10-06 03:02:14 +08:00
1 parent bb96a084e0
commit 5dc9cb1541
7 files changed
+94 -11

No files matched your search

@@ -0,0 +1,20 @@
package handler
import (
"testing"
"time"
)
func TestKnowledgeIndexFailureRemainsVisibleUntilCleared(t *testing.T) {
occurred := time.Now().Add(-time.Hour)
status := map[string]interface{}{}
appendKnowledgeIndexError(status, "test-only embedding failure: 401 Unauthorized", occurred)
if status["last_error"] == nil || status["last_error_time"] != occurred.Format(time.RFC3339) {
t.Fatal("older failure disappeared")
}
cleared := map[string]interface{}{}
appendKnowledgeIndexError(cleared, "", time.Time{})
if _, ok := cleared["last_error"]; ok {
t.Fatal("cleared failure remained")
}
}