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): accept disabled chunk filter in list chunks handler (#16532)
Hz_cb8012e30be9
diff --git a/internal/handler/chunk.go b/internal/handler/chunk.goindex b1b53bd502..0119934700 100644--- a/internal/handler/chunk.go+++ b/internal/handler/chunk.go@@ -351,6 +351,8 @@ func parseAvailableQuery(raw string) (int, bool, error) {return 0, false, nilcase "true", "1":return 1, true, nil+ case "false", "0":+ return 0, true, nildefault:return 0, true, fmt.Errorf("available must be one of: true, false, 1, 0")}diff --git a/internal/handler/chunk_test.go b/internal/handler/chunk_test.goindex 597238386c..1b6decbe15 100644--- a/internal/handler/chunk_test.go+++ b/internal/handler/chunk_test.go@@ -169,6 +169,34 @@ func TestChunkHandlerListChunksMapsPathAndQuery(t *testing.T) {}}+func TestChunkHandlerListChunksMapsAvailableFalse(t *testing.T) {+ mock := &mockChunkSvc{}+ r, h := setupChunkHandlerWithUser("user-1", mock)+ r.GET("/api/v1/datasets/:dataset_id/documents/:document_id/chunks", h.ListChunks)++ mock.listFn = func(req *service.ListChunksRequest, userID string) (*service.ListChunksResponse, error) {+ if userID != "user-1" {+ t.Fatalf("userID = %q, want user-1", userID)+ }+ if req.AvailableInt == nil || *req.AvailableInt != 0 {+ t.Fatalf("available_int = %v, want 0", req.AvailableInt)+ }+ return &service.ListChunksResponse{+ Total: 0,+ Chunks: []map[string]interface{}{},+ Doc: map[string]interface{}{"id": "doc-1"},+ }, nil+ }++ req := httptest.NewRequest(http.MethodGet, "/api/v1/datasets/kb-1/documents/doc-1/chunks?available=false", nil)+ w := httptest.NewRecorder()+ r.ServeHTTP(w, req)++ if w.Code != http.StatusOK {+ t.Fatalf("status = %d, body = %s", w.Code, w.Body.String())+ }+}+func TestChunkHandlerSwitchChunksCallsService(t *testing.T) {mock := &mockChunkSvc{}r, h := setupChunkHandlerWithUser("user-1", mock)