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): surface the underlying error instead of generic 500 for related search and mindmap (#19832)
adws02325018f7ea
diff --git a/internal/handler/chat.go b/internal/handler/chat.goindex 866f279f28..a7b11cd1e7 100644--- a/internal/handler/chat.go+++ b/internal/handler/chat.go@@ -27,6 +27,8 @@ import ("github.com/gin-gonic/gin""ragflow/internal/service"++ "go.uber.org/zap")// ChatHandler chat handler@@ -227,7 +229,8 @@ func (h *ChatHandler) MindMap(c *gin.Context) {TenantSvc: h.tenantSvc,})if err != nil {- jsonInternalError(c, err)+ common.Warn("mindmap failed", zap.String("error", err.Error()))+ common.ResponseWithCodeData(c, common.CodeOperatingError, nil, err.Error())return}common.SuccessWithData(c, mindMap, "success")diff --git a/internal/handler/chat_recommendation.go b/internal/handler/chat_recommendation.goindex 5edfb868de..5245096a74 100644--- a/internal/handler/chat_recommendation.go+++ b/internal/handler/chat_recommendation.go@@ -23,6 +23,8 @@ import ("ragflow/internal/common""ragflow/internal/service"++ "go.uber.org/zap")// ChatRecommendationRequest is the request body for POST /api/v1/chat/recommendation.@@ -59,7 +61,8 @@ func (h *ChatHandler) Recommendation(c *gin.Context) {ctx := c.Request.Context()questions, err := service.GenerateRelatedQuestions(ctx, user.ID, req.Question, req.SearchID, h.searchSvc, h.tenantSvc, h.llm)if err != nil {- jsonInternalError(c, err)+ common.Warn("chat recommendation failed", zap.String("error", err.Error()))+ common.ResponseWithCodeData(c, common.CodeOperatingError, nil, err.Error())return}diff --git a/internal/handler/searchbot.go b/internal/handler/searchbot.goindex 6ee5b10221..e1ee4beb14 100644--- a/internal/handler/searchbot.go+++ b/internal/handler/searchbot.go@@ -157,7 +157,7 @@ func (h *SearchBotHandler) Handle(c *gin.Context) {questions, err := service.GenerateRelatedQuestions(ctx, user.ID, req.Question, req.SearchID, h.searchSvc, h.tenantSvc, h.llm)if err != nil {common.Warn("searchbot related questions failed", zap.String("error", err.Error()))- common.ResponseWithCodeData(c, common.CodeOperatingError, nil, "LLM call failed")+ common.ResponseWithCodeData(c, common.CodeOperatingError, nil, err.Error())return}@@ -387,7 +387,7 @@ func (h *SearchBotHandler) MindMap(c *gin.Context) {})if err != nil {common.Warn("searchbot mindmap failed", zap.String("error", err.Error()))- jsonInternalError(c, err)+ common.ResponseWithCodeData(c, common.CodeOperatingError, nil, err.Error())return}common.SuccessWithData(c, mindMap, "success")diff --git a/internal/service/related_question.go b/internal/service/related_question.goindex dd8267c6b7..09513360cd 100644--- a/internal/service/related_question.go+++ b/internal/service/related_question.go@@ -34,6 +34,9 @@ func GenerateRelatedQuestions(ctx context.Context, tenantID, question, searchID}searchConfig := relatedQuestionsSearchConfig(ctx, searchID, searchSvc)modelID := relatedQuestionsModelID(ctx, tenantID, searchConfig, tenantSvc)+ if modelID == "" {+ return nil, fmt.Errorf("no chat model configured")+ }prompt, err := LoadPrompt("related_question")if err != nil {return nil, err