Skip to content

fix(sql-editor): fail closed on incomplete @set captures#104

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-bec6
Draft

fix(sql-editor): fail closed on incomplete @set captures#104
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-bec6

Conversation

@cursor

@cursor cursor Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

-- @set name = column … / -- @set name = table could capture only the current result page (or silently trim to the 500-row/value cap) while still succeeding. Later ${{…}} expansion then ran against a partial variable with no error — e.g. DELETE … WHERE id IN (${{ids}}) missing most IDs when Max rows/page was smaller than the SELECT.

Root cause

applySetDirectives ignored hasNext / truncated from paged SQL results and sliced list/table payloads to the variable caps without failing.

Fix

  • Fail closed for column/table @set when the result is incomplete (hasNext or truncated) or would exceed the list/table caps.
  • Scalar @set still allows a partial page (only the first cell is used).

Validation

  • Added unit tests for incomplete-page and over-cap refusal.
  • npx vitest run apps/web/src/frontend/lib/sql-variables.test.ts — 28 passed.
Open in Web View Automation 

Column/table @set previously wrote truncated page-0 / capped rows into
variables with no error, so later ${{…}} expansion could silently miss
rows. Refuse incomplete or over-cap captures; scalar @set is unchanged.

Co-authored-by: huy.phan9 <huyplb@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant