Spaces:
Sleeping
Sleeping
Commit ·
39c2d11
1
Parent(s): c8cb83c
fix: prevent NameError when QU disabled and fix connection leak
Browse files- Add route="vector" and sql_query=None defaults before the
`if qu_enabled:` block in both app_cli.py and app_web.py,
preventing NameError when query understanding is disabled.
- Wrap sqlite3 connection in try/finally in sql_retriever.py
to ensure conn.close() runs even if execute/fetchmany raises.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Files changed (3)
274 unmodified lines275276277278279280281282274 unmodified lines original_query = user_input search_query = user_input display_query = user_input route = "vector" sql_query = None
if qu_enabled: with console.status("[bold blue]Understanding your question...[/bold blue]"):153 unmodified lines154155156157158159160161153 unmodified lines
search_query = combined display_query = combined route = "vector" sql_query = None max_clarifications = qu_cfg.get("max_clarifications", 1)
if qu_enabled:50 unmodified lines5152535454555657585955565758596061626350 unmodified lines
try: conn = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True) try: conn.row_factory = sqlite3.Row cursor = conn.execute(sql_query) rows = cursor.fetchmany(max_rows) result = [dict(row) for row in rows] conn.close() return result conn.row_factory = sqlite3.Row cursor = conn.execute(sql_query) rows = cursor.fetchmany(max_rows) return [dict(row) for row in rows] finally: conn.close() except Exception: return []
app_cli.py+2
app_web.py+2
src/sql_retriever.py+7-6