mirror of
https://git.boos.lat/aibo/BossChat.git
synced 2026-10-30 15:16:11 +00:00
fix: propagate document indexing errors to caller
Previously indexing failures were silently logged, returning success even when the embedding model was not configured or Qdrant was down. Now the error is returned to the frontend so the user sees it.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
@@ -111,7 +112,7 @@ func (s *knowledgeDocumentService) CreateKnowledgeDocument(req request.CreateKno
|
||||
return nil, err
|
||||
}
|
||||
if err := rag.Index.IndexDocumentByID(context.Background(), item.ID); err != nil {
|
||||
slog.Error("failed to index created knowledge document", "document_id", item.ID, "error", err)
|
||||
return nil, fmt.Errorf("文档索引失败: %w", err)
|
||||
}
|
||||
item = s.Get(item.ID)
|
||||
return item, nil
|
||||
@@ -160,7 +161,7 @@ func (s *knowledgeDocumentService) UpdateKnowledgeDocument(req request.UpdateKno
|
||||
}
|
||||
|
||||
if err := rag.Index.IndexDocumentByID(context.Background(), req.ID); err != nil {
|
||||
slog.Error("failed to reindex updated knowledge document", "document_id", req.ID, "error", err)
|
||||
return fmt.Errorf("文档重新索引失败: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user