Repository navigation
fix(server): accept curation preview SQL that ends in a comment - #741
Merged
kstonekuan merged 1 commit intoOct 28, 2026
Conversation
Preview wraps the caller's SQL in subqueries. A trailing line comment swallowed the wrapper's closing parenthesis, and a semicolon followed by a comment was not removed, so both returned a 400 that report accepts. Find the terminator the way the SDK does (the last non-comment DuckDB token, by UTF-8 byte offset), and end the body on a new line when it ends in a comment. SQL without a trailing comment is passed through unchanged, and semicolons or comment markers inside strings keep their meaning. Fixes Hebbian-Robotics#738
Contributor
[Low impact] The PR appears safe to merge.
|
kstonekuan
approved these changes
Oct 28, 2026
kstonekuan
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fix. Ruff, ty, and the full suite pass (2,548 passed); reverting the fix fails nine regression cases. Please leave the starter pool for newcomers next time. I’d welcome a real-corpus test run and a report of what breaks or feels awkward.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #738.
Preview wraps the caller's SQL in subqueries (
DESCRIBE, theLIMITprojection, the count,SUMMARIZE). Two endings broke the wrapper:SELECT 1 AS value -- end: the line comment swallowed the wrapper's closing parenthesis.SELECT 1 AS value; -- end(and; /* end */):_stripped_sql_or_refuseonly drops a semicolon at the very end of the string, so this one stayed inside the subquery.The fix is a small
_subquery_bodystep at the top ofrun_preview. It finds the terminator the way the SDK does insrc/hflow/curation.py(the last token DuckDB does not classify as a comment, by UTF-8 byte offset), and ends the body on a new line when the SQL ends in a comment. SQL without a trailing comment is passed through unchanged, so thesqlreturned for ordinary queries is the same as before. Report, pin and saved queries are untouched: they do not wrap the SQL, and they keep the user's text as written.Tests in
packages/hflow-server/tests/test_server_curation_preview.py:; /* end */and a trailing newline, return the same rows and count asSELECT 1 AS value, with and withoutstats: true'a; -- not a comment /* nor this */ tiếng Việt;'inside a string literal comes back intactSELECT 1 AS value; SELECT 2 -- endis still refused as not a single SELECTsqlfor a query without a comment is unchanged9 of the 11 new tests fail on
mainand pass with the fix; the other two (the multi-statement refusal and the unchangedsql) are guards that pass either way.uv sync --locked,ruff check --fix,ruff formatandty checkare clean. The full suite has 2586 passed, 8 skipped and 1 failure,tests/test_lerobot_converter.py::test_success_label_omitted_when_source_has_no_outcome_feature, which also fails in a full run onmainat 7d202bc and passes on its own. It looks order-dependent (connection has an unfinished result from execute(), DuckDB 2), not related to this change.Need help on this PR? Tag
@codesmith-botwith what you need.