You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While building the graph base in #1584, @asclearuc noted that the SQL base packages/ai/src/ai/common/database/db_instance_base.py carries two issues the graph copy already fixes:
_buildSQLQuery returns valid: True after EXPLAIN exhaustion. When EXPLAIN rejects a generated query on every attempt, it returns the last result with isValid still 'true', so get_sql returns {sql, valid: True} and get_data then executes a statement the database already refused, surfacing only an unhelpful "Query execution failed". The graph base sets isValid=False + error on exhaustion (see feat(nodes, ai): add graph base class; make FalkorDB a real graph node #1584, commits 6419df02 / 87e49c3d); the SQL base should do the same.
isValid parsing crashes on a real JSON boolean.db_instance_base does result.get('isValid', '').lower() == 'true' in three places, which raises AttributeError the moment the LLM returns a real JSON boolean (true) instead of the string 'true'. It should go through ai.common.utils.parse_bool (the graph base already switched to it and dropped its local parse_is_valid).
Steps to Reproduce
(issue 1) Point a SQL node (e.g. db_postgres) at a schema and ask a question whose generated query EXPLAIN keeps rejecting → get_sql returns valid: True and get_data executes it, failing with a generic error instead of surfacing the validation error.
(issue 2) Have the LLM answer {"isValid": true, ...} (real bool) → .lower() raises AttributeError.
Expected vs Actual Behavior
Expected: exhausted validation returns valid: False plus the EXPLAIN error; a real-JSON-bool isValid parses without crashing.
Actual:valid: True + blind execution of a rejected query; AttributeError on a JSON-bool isValid.
Severity
Medium — affects the SQL nodes (db_postgres, db_mysql, db_clickhouse, db_arango): degraded error UX plus a crash path on a plausible LLM output.
Platform
Windows
macOS
Linux
Version / Environment
develop, after #1584. Reference fix already in the graph base — port it to db_instance_base.py.
Description
While building the graph base in #1584, @asclearuc noted that the SQL base
packages/ai/src/ai/common/database/db_instance_base.pycarries two issues the graph copy already fixes:_buildSQLQueryreturnsvalid: Trueafter EXPLAIN exhaustion. When EXPLAIN rejects a generated query on every attempt, it returns the last result withisValidstill'true', soget_sqlreturns{sql, valid: True}andget_datathen executes a statement the database already refused, surfacing only an unhelpful "Query execution failed". The graph base setsisValid=False+erroron exhaustion (see feat(nodes, ai): add graph base class; make FalkorDB a real graph node #1584, commits6419df02/87e49c3d); the SQL base should do the same.isValidparsing crashes on a real JSON boolean.db_instance_basedoesresult.get('isValid', '').lower() == 'true'in three places, which raisesAttributeErrorthe moment the LLM returns a real JSON boolean (true) instead of the string'true'. It should go throughai.common.utils.parse_bool(the graph base already switched to it and dropped its localparse_is_valid).Steps to Reproduce
db_postgres) at a schema and ask a question whose generated query EXPLAIN keeps rejecting →get_sqlreturnsvalid: Trueandget_dataexecutes it, failing with a generic error instead of surfacing the validation error.{"isValid": true, ...}(real bool) →.lower()raisesAttributeError.Expected vs Actual Behavior
valid: Falseplus the EXPLAIN error; a real-JSON-boolisValidparses without crashing.valid: True+ blind execution of a rejected query;AttributeErroron a JSON-boolisValid.Severity
Medium — affects the SQL nodes (
db_postgres,db_mysql,db_clickhouse,db_arango): degraded error UX plus a crash path on a plausible LLM output.Platform
Version / Environment
develop, after #1584. Reference fix already in the graph base — port it to
db_instance_base.py.