Skip to content

Report: MySQL Schema Retrieval Failure in Query Router Debug Endpoint #26

@SumitPatel-HQ

Description

@SumitPatel-HQ

Issue Report: MySQL Schema Retrieval Failure in Query Router Debug Endpoint

Overview

The GET /api/v1/databases/{database_id}/tables endpoint within the Query Router (queries.py) fails with a ValueError when targeting MySQL databases. While MySQL is supported in the main query execution path and the Database Router, this specific debug endpoint lacks the necessary branching logic to handle live MySQL connections.

Technical Details

  • Affected File: backend/api/routers/queries.py
  • Affected Function: get_database_tables_info
  • Base Exception: ValueError: Unsupported database type: mysql

Root Cause

The handler at queries.py:615 delegates schema retrieval directly to DatabaseConnectionManager.get_schema. However, DatabaseConnectionManager (and the underlying SchemaIntrospector) only supports internal types (sqlite, postgresql).

MySQL schema retrieval in QueryCraft is implemented as a "Live Service" and requires calling fetch_mysql_schema_from_connection_string, which is imported but unused in this handler.

Impact

  • Severity: Medium (affecting feature parity and debug-ability)
  • User Experience: Users with MySQL connections cannot use the tables debug view, receiving a 500 error instead of a list of tables. This prevents effective debugging of "table not found" errors in the chat interface.

Steps to Reproduce

  1. Connect a live MySQL database to QueryCraft.
  2. Attempt to hit the debug endpoint for that database: GET /api/v1/databases/{db_id}/tables.
  3. The server logs will show a ValueError from schema_introspection.py, and the client will receive a 500 status code.

Evidence of Inconsistency

The main query path at queries.py:163 handles this correctly:

if database.db_type == "mysql":
    schema_data = await fetch_mysql_schema_from_connection_string(database.connection_string)
else:
    schema_data = DatabaseConnectionManager.get_schema(...)

The debug path at queries.py:615 is missing this check:

# CURRENT BROKEN STATE
schema_data = DatabaseConnectionManager.get_schema(
    database.db_type, database.file_path or database.connection_string
)

Recommended Fix

Update the get_database_tables_info function in backend/api/routers/queries.py to include the MySQL branch, matching the pattern used in the query_database function.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions