Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(app): prevent UTF-8 truncation in summary fallback

ChenRussell27d4525ba93d
diff --git a/internal/application/service/knowledge.go b/internal/application/service/knowledge.go
index 3a6b89476..595836d6a 100644
--- a/internal/application/service/knowledge.go
+++ b/internal/application/service/knowledge.go
@@ -2082,7 +2082,11 @@ func (s *knowledgeService) ProcessSummaryGeneration(ctx context.Context, t *asyn
if len(textChunks) > 0 {
summary = textChunks[0].Content
if len(summary) > 500 {
- summary = summary[:500]
+ // Use rune-based truncation to avoid cutting UTF-8 multi-byte characters
+ runes := []rune(summary)
+ if len(runes) > 500 {
+ summary = string(runes[:500])
+ }
}
}
}