Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(parser-config): preserve child chunk settings on save (#20018)

Sbaaoui Idrissf278f3744647
diff --git a/internal/ingestion/pipeline/pipeline_params.go b/internal/ingestion/pipeline/pipeline_params.go
index ff91d25cd1..f51c885da3 100644
--- a/internal/ingestion/pipeline/pipeline_params.go
+++ b/internal/ingestion/pipeline/pipeline_params.go
@@ -291,8 +291,8 @@ func BuildParserConfig(dslJSON []byte, rawConfig map[string]interface{}) entity.
}
// ApplyParentChildChunkerConfig derives runtime children_delimiters from the
-// top-level parent_child setting. Callers with component-scoped chunker edits
-// apply those edits after this mapping.
+// top-level parent_child setting unless the request explicitly configures the
+// chunker itself.
func ApplyParentChildChunkerConfig(componentConfig entity.JSONMap, rawConfig map[string]interface{}) {
parentChild, ok := rawConfig["parent_child"].(map[string]interface{})
if !ok {
@@ -311,6 +311,11 @@ func ApplyParentChildChunkerConfig(componentConfig entity.JSONMap, rawConfig map
if !IsChunkerComponent(componentID) {
continue
}
+ if requested, ok := rawConfig[componentID].(map[string]interface{}); ok {
+ if _, provided := requested["children_delimiters"]; provided {
+ continue
+ }
+ }
params, ok := value.(map[string]interface{})
if !ok {
continue
diff --git a/internal/service/dataset/crud.go b/internal/service/dataset/crud.go
index 88aa4375b9..81c66434a7 100644
--- a/internal/service/dataset/crud.go
+++ b/internal/service/dataset/crud.go
@@ -140,7 +140,15 @@ func (d *DatasetService) CreateDataset(ctx context.Context, req *service.CreateD
}
parserConfig["parent_child"] = parentChild
- pipelinepkg.ApplyParentChildChunkerConfig(parserConfig, map[string]interface{}(parserConfig))
+ parentChildConfig := map[string]interface{}{"parent_child": parentChild}
+ if req.ParserConfig != nil {
+ for componentID, value := range req.ParserConfig {
+ if pipelinepkg.IsChunkerComponent(componentID) {
+ parentChildConfig[componentID] = value
+ }
+ }
+ }
+ pipelinepkg.ApplyParentChildChunkerConfig(parserConfig, parentChildConfig)
var parserConfigMap map[string]interface{} = parserConfig
diff --git a/internal/service/dataset/helpers.go b/internal/service/dataset/helpers.go
index cc1458c6dd..2e02d799c4 100644
--- a/internal/service/dataset/helpers.go
+++ b/internal/service/dataset/helpers.go
@@ -556,7 +556,13 @@ func preserveDatasetParserConfigState(next, existing entity.JSONMap, incoming ma
}
// Re-derive delimiters from parent_child, then keep explicit chunker edits
// (or an existing chunker setting on a partial update) over that fallback.
- pipelinepkg.ApplyParentChildChunkerConfig(next, map[string]interface{}(next))
+ parentChildConfig := map[string]interface{}{"parent_child": parentChild}
+ for componentID, value := range incoming {
+ if pipelinepkg.IsChunkerComponent(componentID) {
+ parentChildConfig[componentID] = value
+ }
+ }
+ pipelinepkg.ApplyParentChildChunkerConfig(next, parentChildConfig)
_, parentChildUpdated := incoming["parent_child"]
for componentID, value := range next {
if !pipelinepkg.IsChunkerComponent(componentID) {
diff --git a/internal/service/document/document_dataset_update.go b/internal/service/document/document_dataset_update.go
index 8b091bbc2e..120e7b614c 100644
--- a/internal/service/document/document_dataset_update.go
+++ b/internal/service/document/document_dataset_update.go
@@ -468,7 +468,7 @@ func (s *DocumentService) updateDocumentParserConfig(ctx context.Context, docume
if _, ok := config["raptor"]; !ok {
delete(merged, "raptor")
}
- pipelinepkg.ApplyParentChildChunkerConfig(merged, merged)
+ pipelinepkg.ApplyParentChildChunkerConfig(merged, config)
return s.documentDAO.UpdateByID(ctx, dao.DB, documentID, map[string]interface{}{
"parser_config": entity.JSONMap(merged),