Skip to content

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

fix(agent): reject only truly-empty delimiter entries on canvas save (#19048)

euvreb54e0e05884c
diff --git a/internal/agent/component/dynamic_params.go b/internal/agent/component/dynamic_params.go
index cb059a9b9e..4ca1dfa044 100644
--- a/internal/agent/component/dynamic_params.go
+++ b/internal/agent/component/dynamic_params.go
@@ -38,12 +38,20 @@ func validateDynamicEntries(value any) error {
func validateDynamicParams(component string, params map[string]any) error {
for _, field := range []string{
"include_domains", "exclude_domains", "site_include", "site_exclude",
- "country_include", "language_include", "delimiters", "children_delimiters",
+ "country_include", "language_include",
} {
if values, ok := params[field].([]any); ok && containsBlank(values) {
return fmt.Errorf("[%s] %s does not support empty entries", component, field)
}
}
+ // Delimiter entries are split tokens, not names: whitespace-only values
+ // ("\n", "\t") are valid delimiters — the chunker form's default row is a
+ // real newline — so only a zero-length string marks an incomplete row.
+ for _, field := range []string{"delimiters", "children_delimiters"} {
+ if values, ok := params[field].([]any); ok && containsEmpty(values) {
+ return fmt.Errorf("[%s] %s does not support empty entries", component, field)
+ }
+ }
switch strings.ToLower(component) {
case "dataoperations":
for _, field := range []string{"select_keys", "remove_keys"} {
@@ -175,3 +183,15 @@ func containsBlank(values []any) bool {
}
return false
}
+
+// containsEmpty reports whether any entry is a zero-length string. Unlike
+// containsBlank it keeps whitespace-only entries, which are meaningful
+// delimiter values.
+func containsEmpty(values []any) bool {
+ for _, value := range values {
+ if s, ok := value.(string); ok && s == "" {
+ return true
+ }
+ }
+ return false
+}
diff --git a/internal/agent/component/dynamic_params_test.go b/internal/agent/component/dynamic_params_test.go
index bdd737aba5..74d29c3816 100644
--- a/internal/agent/component/dynamic_params_test.go
+++ b/internal/agent/component/dynamic_params_test.go
@@ -28,6 +28,15 @@ func TestValidateDynamicEntries(t *testing.T) {
componentDSL("Iteration", map[string]any{"outputs": map[string]any{
"result": map[string]any{"type": "string", "ref": "Iteration@result"},
}}),
+ // Whitespace-only delimiters are legitimate split tokens: the web
+ // form's default row is "\n" (a real newline) and the delimiter
+ // input converts a typed "\n"/"\t" into the raw control character
+ // before saving. They must not be rejected as empty entries.
+ componentDSL("TokenChunker", map[string]any{
+ "delimiter_mode": "delimiter",
+ "delimiters": []any{"\n"},
+ "children_delimiters": []any{"\t"},
+ }),
)
if err := ValidateDynamicEntries(valid); err != nil {
@@ -50,6 +59,8 @@ func TestValidateDynamicEntries(t *testing.T) {
{"loop operator", componentDSL("Loop", map[string]any{"loop_termination_condition": []any{map[string]any{"variable": "count", "operator": "", "value": 3}}}), "loop_termination_condition[0]"},
{"iteration output", componentDSL("Iteration", map[string]any{"outputs": map[string]any{"result": map[string]any{"ref": ""}}}), "outputs.result"},
{"input option", componentDSL("UserFillUp", map[string]any{"inputs": map[string]any{"choice": map[string]any{"options": []any{"one", ""}}}}), "inputs.choice.options"},
+ {"empty delimiter entry", componentDSL("TokenChunker", map[string]any{"delimiters": []any{"ok", ""}}), "delimiters"},
+ {"empty children delimiter entry", componentDSL("TokenChunker", map[string]any{"children_delimiters": []any{""}}), "children_delimiters"},
}
for _, test := range tests {