Skip to content

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

Fix saving agent without compiler id should report error (#19672)

Wang Qi1986030e3fd4
diff --git a/internal/agent/component/dynamic_params.go b/internal/agent/component/dynamic_params.go
index 375c7f013b..c09e86a3a3 100644
--- a/internal/agent/component/dynamic_params.go
+++ b/internal/agent/component/dynamic_params.go
@@ -1,10 +1,15 @@
package component
import (
+ "errors"
"fmt"
"strings"
)
+// ErrCompilationTemplateRequired identifies a Compiler component without a
+// selected compilation template or template group.
+var ErrCompilationTemplateRequired = errors.New("Compilation Template Group does not support empty value")
+
// ValidateDynamicEntries rejects blank values in repeatable Agent parameters.
func ValidateDynamicEntries(dsl map[string]any) error {
return validateDynamicEntries(dsl)
@@ -96,6 +101,10 @@ func validateDynamicParams(component string, params map[string]any) error {
if err := validateExeSQLParams(params); err != nil {
return fmt.Errorf("[%s] %w", component, err)
}
+ case "compiler":
+ if !isNonBlankString(params["compilation_template_id"]) && !isNonBlankString(params["compilation_template_group_id"]) {
+ return fmt.Errorf("[%s] %w", component, ErrCompilationTemplateRequired)
+ }
}
return nil
}
diff --git a/internal/agent/component/dynamic_params_test.go b/internal/agent/component/dynamic_params_test.go
index 91aa1f064f..9a4802edde 100644
--- a/internal/agent/component/dynamic_params_test.go
+++ b/internal/agent/component/dynamic_params_test.go
@@ -29,6 +29,7 @@ func TestValidateDynamicEntries(t *testing.T) {
"result": map[string]any{"type": "string", "ref": "Iteration@result"},
}}),
componentDSL("Message", map[string]any{"text": "hello"}),
+ componentDSL("Compiler", map[string]any{"compilation_template_group_id": "group-1"}),
// 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
@@ -66,6 +67,8 @@ func TestValidateDynamicEntries(t *testing.T) {
{"empty message content", componentDSL("Message", map[string]any{"content": []any{""}}), "Message"},
{"missing message content", componentDSL("Message", map[string]any{}), "Message"},
{"blank message row after valid row", componentDSL("Message", map[string]any{"content": []any{"hello", " "}}), "Message"},
+ {"missing compilation template", componentDSL("Compiler", map[string]any{}), "Compilation Template Group does not support empty value"},
+ {"empty compilation template", componentDSL("Compiler", map[string]any{"compilation_template_group_id": " "}), "Compilation Template Group does not support empty value"},
}
for _, test := range tests {
diff --git a/internal/ingestion/knowledge_compile/nav_lifecycle_test.go b/internal/ingestion/knowledge_compile/nav_lifecycle_test.go
index 3ab6001dc4..50e7d55d2d 100644
--- a/internal/ingestion/knowledge_compile/nav_lifecycle_test.go
+++ b/internal/ingestion/knowledge_compile/nav_lifecycle_test.go
@@ -46,11 +46,11 @@ func (f *recordingNavService) Search(context.Context, string, string, string, []
return nil, nil
}
-func (f *recordingNavService) ListClusters(context.Context, string, string, int, int) ([]nav.NavNode, int64, error) {
+func (f *recordingNavService) ListClusters(context.Context, string, string, string, int, int) ([]nav.NavNode, int64, error) {
return nil, 0, nil
}
-func (f *recordingNavService) ListChildren(context.Context, string, string, string, int, int) ([]nav.NavNode, int64, error) {
+func (f *recordingNavService) ListChildren(context.Context, string, string, string, string, int, int) ([]nav.NavNode, int64, error) {
return nil, 0, nil
}