RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(go-syncer): always use full hierarchical path for Confluence iden… (#19085)
mkaaad50554a02fb89
diff --git a/internal/syncer/connector/confluence.go b/internal/syncer/connector/confluence.goindex 1bc022f935..a8c025ee3d 100644--- a/internal/syncer/connector/confluence.go+++ b/internal/syncer/connector/confluence.go@@ -173,7 +173,6 @@ func (c *ConfluenceConnector) OpenSync(ctx context.Context, request SyncRequest)windowEnd: end,fromBeginning: request.FromBeginning,pageCursor: newConfluenceSearchCursor(c, c.pageCQL(request.WindowStart, end, request.FromBeginning), strings.Join(confluencePageExpansionFields, ",")),- nameCounts: map[string]int{},}if err := session.applyResume(request.Resume); err != nil {return nil, err@@ -543,8 +542,6 @@ type confluenceSyncSession struct {resumeSourceID stringresumeMatched boolresumeUpdatedAt *time.Time-- nameCounts map[string]int}// NextBatch returns the next Confluence document batch, fetching pages,@@ -606,7 +603,7 @@ func (s *confluenceSyncSession) nextDocument(ctx context.Context) (*SourceDocumereturn nil, err}if s.fromBeginning || inConfluenceWindow(doc.UpdatedAt, s.windowStart, s.windowEnd) {- doc.SemanticIdentifier = confluenceSemanticIdentifier(s.currentPage.Space.Name, s.currentPage.ancestorTitles(), s.currentPage.Title, s.nameCounts)+ doc.SemanticIdentifier = confluenceSemanticIdentifier(s.currentPage.Space.Name, s.currentPage.ancestorTitles(), s.currentPage.Title)return &doc, nil}continue@@ -628,7 +625,7 @@ func (s *confluenceSyncSession) nextDocument(ctx context.Context) (*SourceDocumecontinue}if s.fromBeginning || inConfluenceWindow(doc.UpdatedAt, s.windowStart, s.windowEnd) {- doc.SemanticIdentifier = confluenceSemanticIdentifier(firstNonEmpty(s.currentPage.Space.Name, attachment.Space.Name), nil, s.currentPage.Title+" / "+confluenceAttachmentTitle(attachment), s.nameCounts)+ doc.SemanticIdentifier = confluenceSemanticIdentifier(firstNonEmpty(s.currentPage.Space.Name, attachment.Space.Name), s.currentPage.ancestorTitles(), s.currentPage.Title+" / "+confluenceAttachmentTitle(attachment))return &doc, nil}}@@ -851,7 +848,7 @@ func parseConfluenceTime(value string) time.Time {return time.Time{}}-func confluenceSemanticIdentifier(space string, ancestors []string, title string, counts map[string]int) string {+func confluenceSemanticIdentifier(space string, ancestors []string, title string) string {title = firstNonEmpty(title, "Untitled")parts := make([]string, 0, len(ancestors)+2)if space != "" {@@ -859,12 +856,7 @@ func confluenceSemanticIdentifier(space string, ancestors []string, title string}parts = append(parts, ancestors...)parts = append(parts, title)- fullPath := strings.Join(parts, " / ")- counts[title]++- if counts[title] > 1 && fullPath != "" {- return fullPath- }- return title+ return strings.Join(parts, " / ")}func confluenceHTMLText(raw string) string {diff --git a/internal/syncer/connector/confluence_test.go b/internal/syncer/connector/confluence_test.goindex e2ef8fecb6..5765981077 100644--- a/internal/syncer/connector/confluence_test.go+++ b/internal/syncer/connector/confluence_test.go@@ -45,7 +45,7 @@ func TestConfluenceConnectorSyncPagesCommentsAndAttachments(t *testing.T) {if page.SourceID != server.URL+"/wiki/display/SPACE/Page" {t.Fatalf("page SourceID = %q", page.SourceID)}- if page.SemanticIdentifier != "Page" {+ if page.SemanticIdentifier != "Engineering / Root / Page" {t.Fatalf("page SemanticIdentifier = %q", page.SemanticIdentifier)}if !strings.Contains(string(page.Blob), "Hello Confluence") || !strings.Contains(string(page.Blob), "Comment text") {@@ -68,6 +68,9 @@ func TestConfluenceConnectorSyncPagesCommentsAndAttachments(t *testing.T) {if attachment.Extension != ".txt" {t.Fatalf("attachment Extension = %q", attachment.Extension)}+ if attachment.SemanticIdentifier != "Engineering / Root / Page / file.txt" {+ t.Fatalf("attachment SemanticIdentifier = %q", attachment.SemanticIdentifier)+ }if string(attachment.Blob) != "attachment bytes" {t.Fatalf("attachment Blob = %q", string(attachment.Blob))}@@ -341,3 +344,20 @@ func TestConfluenceCQLQuoteEscapesBackslashes(t *testing.T) {t.Fatalf("confluenceCQLQuote() = %q, want %q", got, want)}}++func TestConfluenceSemanticIdentifierAlwaysUsesFullPath(t *testing.T) {+ // Every identifier carries the full hierarchical path: space, ancestors, title.+ got := confluenceSemanticIdentifier("Engineering", []string{"Root"}, "Page")+ if got != "Engineering / Root / Page" {+ t.Fatalf("first occurrence identifier = %q, want full path", got)+ }+ if again := confluenceSemanticIdentifier("Engineering", []string{"Root"}, "Page"); again != got {+ t.Fatalf("later occurrence identifier = %q, want stable %q", again, got)+ }+ if bare := confluenceSemanticIdentifier("", nil, "Standalone"); bare != "Standalone" {+ t.Fatalf("no-space identifier = %q, want title only", bare)+ }+ if unnamed := confluenceSemanticIdentifier("Space", nil, ""); unnamed != "Space / Untitled" {+ t.Fatalf("untitled identifier = %q, want Space / Untitled", unnamed)+ }+}