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(cli): send the dataset_id filter and guard the memory lookup type assertion (#21193)
lemonzoey102d719fd576
diff --git a/internal/cli/common_command.go b/internal/cli/common_command.goindex 8c3bcc943b..4afc7a25e1 100644--- a/internal/cli/common_command.go+++ b/internal/cli/common_command.go@@ -1565,10 +1565,13 @@ func (c *CLI) getMemoryIDByName(memoryName string) (string, error) {return "", err}listMemoriesResponse, ok := response.(*ListMemoriesResponse)- memories := listMemoriesResponse.Data["memory_list"].([]interface{})if !ok {return "", fmt.Errorf("invalid response")}+ memories, ok := listMemoriesResponse.Data["memory_list"].([]interface{})+ if !ok {+ return "", fmt.Errorf("invalid memory_list in response")+ }for _, memory := range memories {var memoryMap map[string]interface{}memoryMap, ok = memory.(map[string]interface{})diff --git a/internal/cli/user_command.go b/internal/cli/user_command.goindex 4830a94772..f513f0229e 100644--- a/internal/cli/user_command.go+++ b/internal/cli/user_command.go@@ -2991,9 +2991,18 @@ func (c *CLI) APIListIngestionTasks(commandCount int, cmd *Command) (ResponseIf,return nil, err}- datasetID, ok := cmd.Params["dataset_id"].(*string)- if !ok {- datasetID = nil+ // The parser stores dataset_id as a plain string (parseQuotedString returns+ // string), so assert string — not *string. The previous .(*string)+ // assertion always failed, silently sending dataset_id: null and making+ // the server return tasks across ALL datasets instead of the requested one.+ // Send the id only when the caller actually provided one; the backend's+ // ListIngestionsRequest.DatasetID is *string and filters only when non-nil,+ // so keep nil (omitted) when no id was given instead of sending "".+ var datasetID any+ if rawID, ok := cmd.Params["dataset_id"].(string); ok {+ if trimmed := strings.TrimSpace(rawID); trimmed != "" {+ datasetID = trimmed+ }}payload := map[string]interface{}{diff --git a/internal/cli/user_command_test.go b/internal/cli/user_command_test.goindex 79dbc851f9..8cac6b984a 100644--- a/internal/cli/user_command_test.go+++ b/internal/cli/user_command_test.go@@ -77,3 +77,79 @@ func TestDevUpdateChunkCommandUsesChunkResource(t *testing.T) {t.Fatalf("unexpected response: %#v", result)}}++// TestAPIListIngestionTasksSendsDatasetIDFilter pins the fix for the wrong+// type assertion: the parser stores dataset_id as a plain string, but the old+// code asserted .(*string), which always failed and sent dataset_id: null —+// so the server returned tasks across ALL datasets instead of the requested+// one. The id must now reach the request body.+func TestAPIListIngestionTasksSendsDatasetIDFilter(t *testing.T) {+ got := make(chan map[string]interface{}, 1)+ client := newTestHTTPClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path != "/api/v1/datasets/ingestion/tasks" || r.Method != http.MethodGet {+ t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path)+ http.NotFound(w, r)+ return+ }+ var payload map[string]interface{}+ if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {+ t.Errorf("decode body: %v", err)+ http.NotFound(w, r)+ return+ }+ got <- payload+ _, _ = fmt.Fprint(w, `{"code":0,"message":"success","data":[]}`)+ }))+ client.useAPIKey = true+ c := &CLI{+ Config: &CommandLineConfig{+ CLIMode: APIMode,+ APIClientConfig: APIModeConfig{CurrentAPIServer: "test"},+ },+ APIServerClientMap: map[string]*HTTPClient{"test": client},+ }+ if _, err := c.APIListIngestionTasks(1, &Command{Params: map[string]interface{}{"dataset_id": "ds-1"}}); err != nil {+ t.Fatalf("APIListIngestionTasks: %v", err)+ }+ select {+ case payload := <-got:+ if payload["dataset_id"] != "ds-1" {+ t.Fatalf("dataset_id = %#v, want \"ds-1\" (filter must reach the body)", payload["dataset_id"])+ }+ default:+ t.Fatal("no request was sent")+ }+}++// TestAPIListIngestionTasksOmitsDatasetIDWhenAbsent confirms the fix keeps+// the "no filter" semantics when the caller does not supply a dataset_id:+// the field must be omitted/null (the server filters only when it is+// non-nil), not an empty string that would trigger a permission check.+func TestAPIListIngestionTasksOmitsDatasetIDWhenAbsent(t *testing.T) {+ got := make(chan map[string]interface{}, 1)+ client := newTestHTTPClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ var payload map[string]interface{}+ _ = json.NewDecoder(r.Body).Decode(&payload)+ got <- payload+ _, _ = fmt.Fprint(w, `{"code":0,"message":"success","data":[]}`)+ }))+ client.useAPIKey = true+ c := &CLI{+ Config: &CommandLineConfig{+ CLIMode: APIMode,+ APIClientConfig: APIModeConfig{CurrentAPIServer: "test"},+ },+ APIServerClientMap: map[string]*HTTPClient{"test": client},+ }+ if _, err := c.APIListIngestionTasks(1, &Command{Params: map[string]interface{}{}}); err != nil {+ t.Fatalf("APIListIngestionTasks: %v", err)+ }+ select {+ case payload := <-got:+ if v, present := payload["dataset_id"]; present && v != nil {+ t.Fatalf("dataset_id = %#v, want omitted or null when no filter given", v)+ }+ default:+ t.Fatal("no request was sent")+ }+}