test: prove scanSync JSON bug with multi-line tokens (expected to FAIL)#148
Open
pyramation wants to merge 2 commits intomainfrom
Open
test: prove scanSync JSON bug with multi-line tokens (expected to FAIL)#148pyramation wants to merge 2 commits intomainfrom
pyramation wants to merge 2 commits intomainfrom
Conversation
These tests demonstrate that scanSync throws 'Bad control character in string literal' when scanning SQL with multi-line tokens (dollar-quoted function bodies, tabs, multi-line C-style comments). The root cause is that build_scan_json() in wasm_wrapper.c only escapes '"' and '\\' in token text, but not '\n', '\r', '\t'. When token text contains literal newlines, the JSON output has unescaped control chars that break JSON.parse. These tests are expected to FAIL on this branch (no fix applied). See PR #147 for the fix.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
3 tasks
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.
Summary
Adds three test cases that are expected to fail on the current
mainbranch, proving thatscanSync/scancannot handle SQL containing multi-line tokens.The root cause:
build_scan_json()infull/src/wasm_wrapper.cescapes"and\in token text but not\n,\r, or\t. When a token spans multiple lines (dollar-quoted function bodies, multi-line/* */comments), the raw JSON contains literal control characters, andJSON.parsethrows"Bad control character in string literal".The three failing tests cover:
CREATE FUNCTIONwith a multi-line PL/pgSQL body$$...$$literal containing actual tab characters/* ... */comment spanning multiple linesAll test SQL uses template literals with actual newlines and tabs so the failing input is visually obvious in the source code (no escape sequences).
Do not merge this PR. It exists to demonstrate the bug. See PR #147 for the fix that makes these tests pass.
Review & Testing Checklist for Human
Test full on *jobs should fail withSyntaxError: Bad control character in string literal in JSONon the three new tests. If they fail for a different reason, something else is wrong.\t— verify it renders as a tab in the diff view, not a run of spaces.Notes
Link to Devin session: https://app.devin.ai/sessions/67facbcfe0ae424bad3eafb4e6ca9059
Requested by: @pyramation