3.1 KiB
3.1 KiB
Task Log: Multi-Tenant Filtering & API Fixes
Date: 2025-01-27 12:45 Mode: beastmode
Todo List Status
- Step 1: Pipeline/Document routes multi-tenant filtering (completed earlier)
- Step 2: Graph routes multi-tenant filtering (10 endpoints updated)
- Step 3: Query/Retrieval routes multi-tenant filtering (3 endpoints updated)
- Step 4: Update lightrag_server.py to pass rag_manager to all routes
- Step 5: Fix API tab visibility - Add /static proxy for Swagger UI assets
- Step 6: Fix "Network connection error" - Allow unauthenticated access when auth disabled
- Step 7: Restart backend server to apply changes
Actions
- Updated
graph_routes.py: Addedget_tenant_ragdependency to all 10 graph endpoints - Updated
query_routes.py: Addedget_tenant_ragdependency to 3 query endpoints - Updated
lightrag_server.py: Passrag_managertocreate_graph_routes()andcreate_query_routes() - Updated
vite.config.ts: Added/staticproxy to fix Swagger UI asset loading - Updated
dependencies.py: Fixedget_tenant_contextto allow unauthenticated access whenauth_configured=Falseandapi_key_configured=False - Restarted backend server to apply the authentication fix
Root Cause Analysis
Issue 1: API Tab White/Blank
- Cause: Swagger UI loads from
/docsbut assets come from/static/swagger-ui/* - Problem: Vite proxy wasn't configured for
/staticpath - Fix: Added
/staticproxy in vite.config.ts
Issue 2: Network Connection Error on Retrieval
- Cause:
get_tenant_contextindependencies.pyrequired authentication even when auth was disabled - Problem: When frontend sends
X-Tenant-IDheader,get_tenant_context_optionalcallsget_tenant_contextdirectly, which always requires auth - Fix: Added check for
auth_configuredandapi_key_configuredinget_tenant_context- if both are False, allow guest access
Decisions
- Used same multi-tenant pattern across all routes:
get_tenant_ragdependency returns tenant-specific LightRAG instance - For auth fix: Added guest user with "viewer" role when no auth is configured
Next Steps
- Test all screens with tenant/KB switching to verify data isolation
- Verify API tab displays Swagger UI correctly
- Test retrieval queries work without authentication errors
Lessons/Insights
- When
X-Tenant-IDis provided in headers,get_tenant_context_optionalpropagates errors instead of falling back to None - The auth logic in
dependencies.pywas inconsistent withutils_api.py- both now respect "no auth required" mode - Swagger UI loads static assets from a separate path (
/static/) that needs explicit proxy configuration
Files Modified
lightrag/api/routers/graph_routes.py- Multi-tenant support for all graph endpointslightrag/api/routers/query_routes.py- Multi-tenant support for all query endpointslightrag/api/lightrag_server.py- Pass rag_manager to graph and query route creatorslightrag/api/dependencies.py- Allow unauthenticated access when auth is disabledlightrag_webui/vite.config.ts- Added/staticproxy for Swagger UI assets