Skip to content

fix(ai): run_sql reruns misspelt column names and keeps internal SQL out of errors - #1959

Merged
Makisuo merged 13 commits into
mainfrom
fix/run-sql-identifier-hints
Oct 30, 2026
Merged

Makisuo merged 13 commits into
mainfrom
fix/run-sql-identifier-hints

fix(ai): decline a qualified fix when its qualifier names two relations

414492e
Select commit
Loading
Failed to load commit list.
Maple Review Bot / Maple / review succeeded Oct 30, 2026 in 1m 36s

Confidence 10/10 · No issues found

🟢 Confidence 10/10 · safe to merge
New guard only declines rewrites, and the added test fails without it; earlier regex edge cases are pinned by behaviour tests.
no findings · tests covered · risk low

run_sql now rewrites an unambiguous misspelt column and reruns, and scrubs internal SQL out of warehouse errors. The change since the last review only adds a guard that declines a qualified fix when its qualifier names two relations, and it is correct.

  • fixUnknownIdentifier declines a qualified rewrite when qualifierReused sees the qualifier bound by two relations
  • sql-identifiers.test.ts pins the CTE-plus-table qualifier case
What was checked
  • Walked the new CTE case through identifierFix without the guard: it rewrote all three t.span_name uses, so the test does fail without qualifierReused
  • identifierText keeps every position when blanking literals/comments and unquoting backticks, so replaceIdentifier spans line up with sql
  • Global SQL_TOKEN/RELATION regexes are only used through replace/matchAll, which do not carry lastIndex between calls

414492e · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.