From 699a25c19cc789e75a62838eea9f8f2cc1c6d3a5 Mon Sep 17 00:00:00 2001 From: euvre <93761161+euvre@users.noreply.github.com> Date: Wed, 8 Jul 2026 10:03:58 +0800 Subject: [PATCH] fix(service): allow updating memory_type when memory is empty (#16668) --- build.sh | 2 +- internal/service/memory.go | 11 ++++++++--- web/.env.development | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 7f63d94d6..04c683cd5 100755 --- a/build.sh +++ b/build.sh @@ -439,7 +439,7 @@ run() { sleep 1 print_section "Starting RAGFlow server (foreground)" - "$RAGFLOW_SERVER_BINARY" -- api + "$RAGFLOW_SERVER_BINARY" --api } # Show help diff --git a/internal/service/memory.go b/internal/service/memory.go index e1f59aaee..51250113f 100644 --- a/internal/service/memory.go +++ b/internal/service/memory.go @@ -671,15 +671,20 @@ func (s *MemoryService) UpdateMemory(tenantID string, memoryID string, req *Upda return formatRetDataFromMemory(currentMemory), nil } - memorySize := currentMemory.MemorySize notAllowedUpdate := []string{} for _, f := range []string{"tenant_embd_id", "embd_id", "memory_type"} { - if _, ok := updateDict[f]; ok && memorySize > 0 { + if _, ok := updateDict[f]; ok { notAllowedUpdate = append(notAllowedUpdate, f) } } if len(notAllowedUpdate) > 0 { - return nil, fmt.Errorf("can't update %v when memory isn't empty", notAllowedUpdate) + messages, err := s.listMemoryMessages(context.Background(), currentMemory, []string{}, "", 1, 1) + if err != nil { + return nil, fmt.Errorf("failed to check memory messages: %w", err) + } + if total, ok := messages["total_count"].(int64); ok && total > 0 { + return nil, fmt.Errorf("can't update %v when memory isn't empty", notAllowedUpdate) + } } if _, ok := updateDict["memory_type"]; ok { diff --git a/web/.env.development b/web/.env.development index bc3a84770..9131e59a7 100644 --- a/web/.env.development +++ b/web/.env.development @@ -1,2 +1,2 @@ VITE_BASE_URL='/' -API_PROXY_SCHEME='python' \ No newline at end of file +API_PROXY_SCHEME='go'