From cedb3d49d20351fb5b661aca832a74bf25b3655f Mon Sep 17 00:00:00 2001 From: BukeLy Date: Thu, 20 Nov 2025 03:09:46 +0800 Subject: [PATCH] fix: pass workspace to LightRAG instance instead of vector_db_storage_cls_kwargs Why this change is needed: LightRAG creates storage instances by passing its own self.workspace field, not the workspace parameter from vector_db_storage_cls_kwargs. This caused E2E tests to fail because the workspace was set to default "_" instead of the configured value like "prod" or "workspace_a". How it solves it: - Pass workspace directly to LightRAG constructor as a field parameter - Remove workspace from vector_db_storage_cls_kwargs where it was being ignored - This ensures self.workspace is set correctly and propagated to storage instances Impact: - Fixes test_backward_compat_old_workspace_naming_qdrant migration failure - Fixes test_workspace_isolation_e2e_qdrant workspace mismatch - Proper workspace isolation is now enforced in E2E tests Testing: - Modified two Qdrant E2E tests to use correct workspace configuration - Tests should now find correct legacy collections (e.g., prod_chunks) --- tests/test_e2e_multi_instance.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_e2e_multi_instance.py b/tests/test_e2e_multi_instance.py index c32a473c..fe8650b7 100644 --- a/tests/test_e2e_multi_instance.py +++ b/tests/test_e2e_multi_instance.py @@ -896,17 +896,15 @@ async def test_backward_compat_old_workspace_naming_qdrant( ) # Important: Use "prod" workspace to match old naming - updated_config = {**qdrant_config} - updated_config["workspace"] = "prod" - rag = LightRAG( working_dir=temp_dir, + workspace="prod", # Pass workspace to LightRAG instance llm_model_func=mock_llm_func, embedding_func=embedding_func, tokenizer=mock_tokenizer, vector_storage="QdrantVectorDBStorage", vector_db_storage_cls_kwargs={ - **updated_config, + **qdrant_config, "cosine_better_than_threshold": 0.8, }, ) @@ -1016,13 +1014,13 @@ async def test_workspace_isolation_e2e_qdrant( # Instance A: workspace_a rag_a = LightRAG( working_dir=temp_working_dirs["workspace_a"], + workspace="workspace_a", # Pass workspace to LightRAG instance llm_model_func=mock_llm_func, embedding_func=embedding_func, tokenizer=mock_tokenizer, vector_storage="QdrantVectorDBStorage", vector_db_storage_cls_kwargs={ **qdrant_config, - "workspace": "workspace_a", "cosine_better_than_threshold": 0.8, }, ) @@ -1030,13 +1028,13 @@ async def test_workspace_isolation_e2e_qdrant( # Instance B: workspace_b rag_b = LightRAG( working_dir=temp_working_dirs["workspace_b"], + workspace="workspace_b", # Pass workspace to LightRAG instance llm_model_func=mock_llm_func, embedding_func=embedding_func, tokenizer=mock_tokenizer, vector_storage="QdrantVectorDBStorage", vector_db_storage_cls_kwargs={ **qdrant_config, - "workspace": "workspace_b", "cosine_better_than_threshold": 0.8, }, )