dataease / dataease/SQLBot

[BUG]SQL Parsing Fails for Valid LLM Outputs with Non-Standard JSON Structure

Offen
#725 4 Kommentare 0 Reaktionen 2 zugewiesene Personen Auf GitHub ansehen

@xuwei-fit2cloud arbeitet bereits daran.

Seit 02.1.2026.

bug
Vorherrschende Sprache
JavaScript
Sterne
6.8k
Forks
882
Ø Merge
4 Std. 37 Min.
Gemergte PRs (30 T.)
32

Beschreibung

SQLBot Version
1.5.1
Run Mode
Is it running in a Docker container or running from source code?
Docker
Describe the bug
When using local or open-source LLMs (e.g. Qwen2.5-32B, Qwen3-32B, LLaMA 3.x), SQLBot fails to parse valid SQL generated by the model and raises the error:
Cannot parse sql from answer
This happens even though the LLM output contains a correct and executable SQL statement.
The failure is caused by SQLBot relying on a strict JSON schema for parsing, while many LLMs return SQL in alternative but reasonable formats.
To Reproduce
Deploy SQLBot 1.5.1 using Docker
Configure a local LLM (Qwen2.5-32B / Qwen3-32B / LLaMA 3.x) via Ollama or vLLM
Ask a simple SQL question (e.g. daily aggregation query)
Let the LLM generate SQL
Observe the error:Cannot parse sql from answer
Example LLM output that is rejected:{
"query": "SELECT SUM(chulu_guoshu) FROM example_table WHERE DATE(insert_time) = '2025-12-31'"
}

Expected behavior
SQLBot should successfully extract and execute SQL as long as the generated SQL is valid, including cases such as:
{ "query": "SELECT ..." }
{ "sql": "SELECT ..." }
Nested JSON containing SQL
Plain SQL strings starting with SELECT
The system should not require a single rigid JSON structure for SQL parsing.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
SQLBot rejects valid SQL outputs that do not strictly match the expected JSON schema and throws:Cannot parse sql from answer
Additional context
This is not an SQL generation issue — the SQL itself is correct
The problem occurs at the SQL parsing stage only
Cloud models tend to follow the expected format, but local/open-source models do not
This significantly limits SQLBot’s usability with local LLM deployments
A more tolerant SQL extraction mechanism or fallback for raw SQL would greatly improve compatibility.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.