-
Notifications
You must be signed in to change notification settings - Fork 31
Load DB in steps #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load DB in steps #161
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds MCP support and router mounting, introduces streaming database connection steps, implements API token management (backend endpoints, frontend UI/TS, styles, templates), updates auth to accept API tokens, tightens typings, and revises docs/config (Docker-first, MCP toggle, env variables). Dependencies updated (fastapi-mcp, litellm bump). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant FE as Frontend (Modal)
participant BE as FastAPI /database
participant Loader as Schema Loader
U->>FE: Click "Connect"
FE->>BE: POST /database { url }
BE-->>FE: stream: reasoning_step "Starting connection"
BE->>BE: Detect DB type (postgres/mysql)
BE-->>FE: stream: reasoning_step "Detected type: X"
BE->>Loader: load schema
alt success
BE-->>FE: stream: final_result { success, schema }
FE->>FE: Show success step, close modal, reload
else error
BE-->>FE: stream: error { message }
FE->>FE: Show error step/alert
end
sequenceDiagram
autonumber
participant C as Client
participant APP as FastAPI App
participant MCP as FastApiMCP
C->>APP: Startup
APP->>APP: Read DISABLE_MCP
alt MCP enabled
APP->>MCP: Initialize "queryweaver" ops
APP->>APP: mount /mcp endpoints
else MCP disabled
APP->>APP: Skip MCP mount
end
sequenceDiagram
autonumber
participant U as User
participant FE as Token Modal (TS)
participant API as /api/tokens
participant Auth as token_required
U->>FE: Open "API Tokens"
FE->>API: GET /list (credentials)
API->>Auth: Validate (OAuth or API token)
API-->>FE: { tokens: [...] }
U->>FE: Generate token
FE->>API: POST /generate
API-->>FE: { token_id, created_at }
FE->>FE: Show full token once
U->>FE: Delete token
FE->>API: DELETE /{last4}
API-->>FE: 200 OK
FE->>FE: Refresh list, show success
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Dependency ReviewThe following issues were found:
|
| except (ValueError, TypeError) as e: | ||
| logging.error("Unexpected error in database connection: %s", str(e)) | ||
| raise HTTPException(status_code=500, detail="Internal server error") | ||
| return StreamingResponse(generate(), media_type="application/json") |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information flows to this location and may be exposed to an external user.
Stack trace information flows to this location and may be exposed to an external user.
Stack trace information flows to this location and may be exposed to an external user.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To address the vulnerability of exposing internal error information to users, the fix must prevent potentially sensitive data from being returned in streamed JSON responses. To do this, the PostgresLoader.load method (in api/loaders/postgres_loader.py) must never yield detailed exception messages, instead only yielding generic, safe error messages. Internal details can and should be logged on the server.
- Update the
exceptblocks inPostgresLoader.loadso that, instead of yielding f-strings containingstr(e), they log that info and only yield a sanitized message to the caller (route). - No changes are required in the route itself if we can guarantee that loader always yields only generic error messages (as the route already returns friendly error text in other places).
- Only file
api/loaders/postgres_loader.pyrequires editing to update the error yielding logic.
-
Copy modified lines R109-R110 -
Copy modified lines R112-R113
| @@ -106,9 +106,11 @@ | ||
| f"Found {len(entities)} tables.") | ||
|
|
||
| except psycopg2.Error as e: | ||
| yield False, f"PostgreSQL connection error: {str(e)}" | ||
| logging.error("PostgreSQL connection error: %s", str(e)) | ||
| yield False, "Could not connect to the PostgreSQL database. Please check the connection details." | ||
| except Exception as e: | ||
| yield False, f"Error loading PostgreSQL schema: {str(e)}" | ||
| logging.exception("Unexpected error while loading PostgreSQL schema: %s", str(e)) | ||
| yield False, "An internal error occurred while loading the PostgreSQL schema." | ||
|
|
||
| @staticmethod | ||
| def extract_tables_info(cursor) -> Dict[str, Any]: |
Fix #160
Summary by CodeRabbit